Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add property-based tests #142

Closed
barrucadu opened this issue Oct 28, 2017 · 2 comments
Closed

Add property-based tests #142

barrucadu opened this issue Oct 28, 2017 · 2 comments

Comments

@barrucadu
Copy link
Owner

barrucadu commented Oct 28, 2017

There are certainly some things which could benefit from property testing, if someone was willing to write the Arbitrary or Listable instances. Here are a few I spotted skimming through Test.DejaFu.SCT.Internal:

  • \ds tid act -> canInterrupt ds tid act ==> canInterruptL ds tid (rewind act)
  • dependentActions is commutative
  • \mem ds tid1 ta1 tid2 ta2 -> dependent mem ds tid1 ta1 tid2 ta2 ==> dependent' mem ds tid1 ta1 tid2 (rewind ta2) (I think that should be the case...)

I suspect the various Test.DejaFu.Conc.Internal modules and Test.DejaFu.Common will be fruitful as well. Depending on how crazy you want to get, you could even check that Eq and Ord instances are consistent, where one or both is hand-written.

This is worthwhile because there's a lot of logic which differs only in whether it accepts a ThreadAction or a Lookahead value. The ThreadAction case is supposed to be the more accurate case, whereas the Lookahead case is supposed to be the more pessimistic case, so checking that (eg with implication if it's a predicate) would help make sure there aren't any mistakes.

barrucadu added a commit that referenced this issue Oct 30, 2017
Goes some way to solving #142, but it would be nice to have some for
the memory stuff.
barrucadu added a commit that referenced this issue Oct 30, 2017
Goes some way to solving #142, but it would be nice to have some for
the memory stuff.
@barrucadu
Copy link
Owner Author

barrucadu commented Oct 30, 2017

Added some tests, but it would be nice to have some for the memory implementation as well. However, I'm not really sure how to best add those, as leancheck doesn't do monadic properties.

At the moment runST would work, but in implementing bound threads, everything is changing over to IO. Maybe that module should keep using MonadRef, as it won't acquire any IO-specific code.

barrucadu added a commit that referenced this issue Oct 30, 2017
Goes some way to solving #142, but it would be nice to have some for
the memory stuff.
barrucadu added a commit that referenced this issue Oct 30, 2017
Goes some way to solving #142, but it would be nice to have some for
the memory stuff.
barrucadu added a commit that referenced this issue Oct 30, 2017
Goes some way to solving #142, but it would be nice to have some for
the memory stuff.
@barrucadu
Copy link
Owner Author

An alternative to fitting MonadRef back into the bound branch would be to define an orphan MonadConc (ST t) instance for testing, which simply defines CRef, readCRef, and atomicWriteCRef, leaving everything else undefined.

This is probably a far smaller change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant