chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Optionally implement Arbitrary for Naive{Date,Time,DateTime}

Open asayers opened this issue 4 years ago • 3 comments
trafficstars

I'm not sure if you guys are interested in taking a change like this. If you are, I'd be happy to fill in more impls.

asayers avatar May 04 '21 11:05 asayers

It seems like arbitrary is intended for use by fuzzers, are there examples of its use elsewhere? I don't have a lot of context from this PR.

quodlibetor avatar May 07 '21 19:05 quodlibetor

@quodlibetor I'd love to use it. It's not only for crazy fuzzers but also for something what is rather a property based testing. E.g. particulary in my case: I have number of relative big domain models, which then transformed into DB records. I have also transformer functions that works in the opposite direction. Currently if I want to unit test it, the amount of tests I have to write is proportional to the complexity of the structures I have. I could use Arbitrary it would be just a couple lines of code:

  • Generate a random domain model
  • Transform it to DB records
  • Transform DB records back
  • Compare the original model with that one we got

This test would be much more smaller and, what is also important, not biased (unlike me, a developer).

greyblake avatar Aug 13 '22 20:08 greyblake

If someone is willing to rebase or resubmit it, I would certainly consider it worthwhile.

djc avatar Aug 13 '22 21:08 djc

@djc Hi! The PR was rebased (unfortunately I also missed that). Would you consider merging the PR or is there something else is required to get it merged?

greyblake avatar Oct 11 '22 07:10 greyblake

@asayers @djc @conradludgate

I am very interested in this support of Arbitrary. Since @asayers apparently has no time to address the code review, I've done it on my own and opened a new PR: https://github.com/chronotope/chrono/pull/848 (which is alternative to this one)

greyblake avatar Oct 17 '22 11:10 greyblake

@djc This one can be closed, since https://github.com/chronotope/chrono/pull/849 was merged.

greyblake avatar Oct 18 '22 12:10 greyblake