mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-12-18 19:11:37 +03:00
3af7d4206d
This lets dejafu test CoCo-style properties, and introduces a dependency on [leancheck][]. For example, consider this statement about MVars: "using readMVar is better than a takeMVar followed by a putMVar because the former is atomic but the latter is not." This module can test properties like that: ``` sig e = Sig { initialise = maybe newEmptyMVar newMVar , observe = \v _ -> tryReadMVar v , interfere = \v s -> tryTakeMVar v >> maybe (pure ()) (void . tryPutMVar v) s , expr = e } > check $ sig (void . readMVar) `equivalentTo` sig (\v -> takeMVar v >>= putMVar v) *** Failure: (seed Just ()) left: [(Nothing,Just ())] right: [(Nothing,Just ()),(Just Deadlock,Just ())] ``` The two expressions are not equivalent, and we get given the counterexample! In addition to "equivalentTo", there is also "refines" and "strictlyRefines" (and negated variants) [leancheck]: https://hackage.haskell.org/package/leancheck
27 lines
488 B
YAML
Executable File
27 lines
488 B
YAML
Executable File
flags: {}
|
|
|
|
packages:
|
|
- concurrency
|
|
- dejafu
|
|
- dejafu-tests
|
|
- hunit-dejafu
|
|
- tasty-dejafu
|
|
# Until test-framework-hunit with HUnit 1.6 support is on Stackage:
|
|
# https://github.com/haskell/test-framework/pull/27
|
|
- location:
|
|
git: https://github.com/haskell/test-framework.git
|
|
commit: 7d9c1a67f41da960152657728da7813c533573f2
|
|
subdirs:
|
|
- hunit
|
|
extra-dep: true
|
|
|
|
extra-deps:
|
|
- call-stack-0.1.0
|
|
- HUnit-1.6.0.0
|
|
- leancheck-0.6.2
|
|
|
|
resolver: nightly-2016-06-20
|
|
|
|
nix:
|
|
packages: [git]
|