advancedtelematic / quickcheck-state-machine

Test monadic programs using state machine based models
Other
203 stars 25 forks source link

Support QuickCheck 2.12 #248

Closed kderme closed 5 years ago

kderme commented 5 years ago

QuickCheck-2.12.* introduced a breaking change for quickcheck-state-machine https://github.com/nick8325/quickcheck/commit/b2043969600c9492db1b2fbfa642a10fa1b2665f#diff-b94eb0159d0972b11367d7b09d647ee6

For QuickCheck-2.12.* to be supported, this change is necessary:

diff --git a/src/Test/StateMachine/Sequential.hs b/src/Test/StateMachine/Sequential.hs
index 82d2955..d2adfef 100644
--- a/src/Test/StateMachine/Sequential.hs
+++ b/src/Test/StateMachine/Sequential.hs
@@ -376,7 +376,7 @@ checkCommandNames :: forall cmd. (Generic1 cmd, GConName1 (Rep1 cmd))
                   => Commands cmd -> Property -> Property
 checkCommandNames cmds
   = collect names
-  . cover (length names == numOfConstructors) 1 "coverage"
+  . cover 1 (length names == numOfConstructors) "coverage"
   where
     names             = commandNames cmds
     numOfConstructors = length (gconNames1 (Proxy :: Proxy (Rep1 cmd Symbolic)))
kderme commented 5 years ago

Also note here http://hackage.haskell.org/package/quickcheck-state-machine there is no upper limit to the version of QuickCheck. This makes the build fail for version 2.12 with sth like

src/Test/StateMachine/Sequential.hs:379:12: error:
    • Couldn't match expected type ‘Double’ with actual type ‘Bool’
    • In the first argument of ‘cover’, namely
        ‘(length names == numOfConstructors)’
      In the second argument of ‘(.)’, namely
        ‘cover (length names == numOfConstructors) 1 "coverage"’
      In the expression:
        collect names
          . cover (length names == numOfConstructors) 1 "coverage"
    |
379 |   . cover (length names == numOfConstructors) 1 "coverage"
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build quickcheck-state-machine-0.4.2 (which is required by
test:tests from ouroboros-network-0.1.0.0, test:test-storage from
ouroboros-network-0.1.0.0 and others).
stevana commented 5 years ago

I've added an upper bound in HEAD: https://github.com/advancedtelematic/quickcheck-state-machine/commit/5fc812b2e5848a190b06909e42be4478ed1538a2, I should try to make a new release soon.

stevana commented 5 years ago

I believe this is fixed in the above commit, if not please reopen the issue.