Commit Graph

640 Commits

Author SHA1 Message Date
Michael Walker
2cc812ddc3 Make checkWithSeeds faster when the result can be inferred early
Often checking every seed is unnecessary to compute the result of
checkWithSeeds.  The first failure always suffices for weak refinement
and equivalence, and sometimes suffices for strict refinement.
2017-06-09 15:14:42 +01:00
Michael Walker
d46319c577 Make checkFor faster when there is only a single counterexample
As mapM in IO is strict, composing listToMaybe with counterExamples
necessitates finding ALL counterexamples first, even though only the
first is returned.  So an improvement is gained by manually making it
"lazy".
2017-06-09 15:14:26 +01:00
Michael Walker
a0a5a493d5 Bump versions for release 2017-06-07 17:09:01 +01:00
Michael Walker
8f27ff0c11 Merge branch 'next-major' 2017-06-07 16:59:40 +01:00
Michael Walker
6bc2fd044f Remove unused imports 2017-06-07 16:59:24 +01:00
Michael Walker
f590f233a8 Implement all nonsense checks directly in the sct* functions 2017-06-07 16:50:56 +01:00
Michael Walker
040580d4f2 Remove bound-specific SCT functions 2017-06-07 16:50:56 +01:00
Michael Walker
6b1fd17024 Implement uniform random scheduling
Adds a new `uniformly` smart constructor and `sctUniformRandom`
function.

Also renames `sctRandom` to `sctWeightedRandom`.
2017-06-07 16:50:56 +01:00
Michael Walker
1146ce9b38 Add a smart constructor for constructing swarmy executions
The `randomly` constructor now corresponds exactly to the old
`Randomly`.

Also refactor tests a bit.
2017-06-07 16:50:56 +01:00
Michael Walker
fba26e6c73 Make Way abstract and expose smart constructors 2017-06-07 16:50:56 +01:00
Michael Walker
d65b8359a9 Allow re-using the weights for multiple executions in sctRandom 2017-06-07 16:45:43 +01:00
Michael Walker
a0698bf575 Merge branch 'propcheck'
Closes #82
2017-06-07 14:32:19 +01:00
Michael Walker
748a55d813 Re-export Test.DejaFu.Refinement from Test.DejaFu 2017-06-07 14:25:55 +01:00
Michael Walker
94e22a765e Add tests for refinement checking
New coverage report, as there have been a bunch of new tests since the
one in the CONTRIBUTING file was generated:

 54% expressions used (4311/7948)
 51% boolean coverage (67/131)
      47% guards (50/106), 31 always True, 6 always False, 19 unevaluated
      57% 'if' conditions (11/19), 2 always True, 1 always False, 5 unevaluated
     100% qualifiers (6/6)
 61% alternatives used (413/671)
 83% local declarations used (212/254)
 28% top-level declarations used (313/1099)
2017-06-07 14:25:55 +01:00
Michael Walker
e785e51ddc Expose refinement properties in hunit-dejafu and tasty-dejafu 2017-06-07 14:20:04 +01:00
Michael Walker
a62350dd5c Switch to new refinement operators used in CoCo
Also include some explanation of this apparently backwards notation.
2017-06-07 14:20:00 +01:00
Michael Walker
3af7d4206d Implement refinement property testing
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
2017-06-07 14:18:50 +01:00
Michael Walker
4ffd7587ad Define default text execution parameters in Test.DejaFu.Defaults 2017-05-31 15:26:27 +01:00
Michael Walker
44c31f879c Update test-framework-hunit git location 2017-05-31 15:08:06 +01:00
Michael Walker
b6713505c5 Prevent re-use of MVar, CRef, and TVar IDs inside subconcurrency.
Fixes #81.
2017-05-03 23:12:26 +01:00
Michael Walker
c11f1d92db Test case for #81.
This is a large diff because it pulls in a variant of QSemN.
2017-05-03 23:09:56 +01:00
Michael Walker
2d97030abe tasty-dejafu-0.5.0.0 2017-04-08 21:18:20 +01:00
Michael Walker
9af76cc4f2 hunit-dejafu-0.5.0.0 2017-04-08 21:15:32 +01:00
Michael Walker
dd5748e3e6 dejafu-0.6.0.0 2017-04-08 21:08:03 +01:00
Michael Walker
efaf353920 Rename Conc to ConcT and turn into a MonadTrans.
Closes #70.
2017-04-08 20:59:05 +01:00
Michael Walker
d3062234fa Make Way a GADT.
Closes #65.
2017-04-08 20:57:25 +01:00
Michael Walker
94c4afe090 CHANGELOG errata: dejafu-0.5.1.2 should have been 0.5.2.0.
Introducing new non-orphan typeclass instances is a minor bump.
2017-04-08 20:21:22 +01:00
Michael Walker
9c33eff1f7 Add Haddock @since annotations to everything in dejafu/hunit/tasty 2017-04-08 20:21:22 +01:00
Michael Walker
98af53bbc3 Consider Test.DejaFu.Common part of the public API. 2017-04-08 20:21:22 +01:00
Michael Walker
ab599b637d Add guidance on documenting changes to CONTRIBUTING. 2017-04-08 20:21:22 +01:00
Michael Walker
6b71e9a76f Remove the internal SCT graphviz functions. 2017-04-08 10:38:06 +01:00
Michael Walker
da09c2268a Inline the findSchedulePrefix predicate.
The function is only used in one place, with a constant
predicate. There was no point in it being a parameter.
2017-04-08 10:34:46 +01:00
Michael Walker
5f9ad29b1b Include READMEs in cabal sdists.
Closes #79.
2017-04-08 10:30:58 +01:00
Michael Walker
93d8cc64e3 Add a separate CONTRIBUTING file. 2017-04-08 05:55:42 +01:00
Michael Walker
d4df9eed0c Add section on code style to README + scripts to run tools.
- `lint.sh` runs HLint, returning 1 if HLint is NOT version 1 (as the
  .hlint.yaml configuration file is only supported in version 2 and
  later) AND issues are found.

- `style.sh` runs stylish-haskell. I would like it to return 1 if it
  reformatted anything, but the tool doesn't appear to support
  reporting that :(
2017-04-08 05:42:26 +01:00
Michael Walker
f90ecb2125 Change "Code Coverage" to "Test Coverage" in README. 2017-04-08 05:42:25 +01:00
Michael Walker
cc27e03d6d Use stylish-haskell to format import lists. 2017-04-08 05:42:25 +01:00
Michael Walker
d934222fe7 Implement isEmptyMVar in terms of tryRead, not tryTake. 2017-04-08 05:42:25 +01:00
Michael Walker
5cd55a1921 Add an HLint2 config file & fix warnings. 2017-04-08 05:42:25 +01:00
Michael Walker
0080678a65 Add a repo-wide changelog.
Closes #78.
2017-04-07 20:22:22 +01:00
Michael Walker
de8ced69a6 Fiddle with changelog format. 2017-04-07 20:05:11 +01:00
Michael Walker
60f771d50e Write changelogs. 2017-04-07 18:16:30 +01:00
Michael Walker
8d23a2715e Bump concurrency to 1.1.2.0 and dejafu to 0.5.1.3. 2017-04-05 21:41:22 +01:00
Michael Walker
7cd0c665fa Add Haddock "@since" comments to everything in concurrency. 2017-04-05 21:25:02 +01:00
Michael Walker
da9f622ca9 Add Stackage LTS-8 to the travis config. 2017-04-05 21:06:25 +01:00
Michael Walker
a4ab84e132 Only define Semigroup Async instance for base >= 4.9.0.0. 2017-04-05 21:01:23 +01:00
Michael Walker
1532a75f78 Add replicateConcurrently{,_} to Async. 2017-04-05 20:57:27 +01:00
Michael Walker
92de856ed0 Add concurrently_, mapConcurrently_, and forConcurrently_. 2017-04-05 20:56:20 +01:00
Michael Walker
2e7aeac8b3 Add Semigroup and Monoid instances for Concurrently. 2017-04-05 20:54:21 +01:00
Michael Walker
71beaed0e5 Add uninterruptibleCancel to Async. 2017-04-05 20:46:00 +01:00