Reputation: 7394
Im trying to go from from _prop example to write the same thing in Tasty. (example from http://primitive-automaton.logdown.com/posts/142511/tdd-with-quickcheck)
game9_prop :: Game9 -> Bool
game9_prop = (9==) . length . unGame . unGame9
This is what I'm trying in tasty:
qcTestGengame9 :: TestTree
qcTestGengame9 = QC.testProperty "Better gen rate" $
\ (g :: Game9) -> length . unGame . unGame9 g == 9 --ERROR LINE
This conversion gives me the following error:
test/Tasty.hs:53:11:
Illegal type signature: `Game9'
Perhaps you intended to use -XScopedTypeVariables
In a pattern type-signature
This is the type Game9:
-- To make generation rate better
newtype Game9 = Game9 { unGame9 :: Game }
deriving (Eq, Show)
instance Arbitrary Game9 where
arbitrary = (Game9 . Game) `liftM` replicateM 9 arbitrary
Upvotes: 0
Views: 171
Reputation: 2329
To fix the immediate error, remove the type annotation, i.e., use
qcTestGengame9 :: TestTree
qcTestGengame9 = QC.testProperty "Better gen rate" $
\ g -> (length . unGame . unGame9) g == 9
The expression unGame9 g
already ensures g :: Game9
.
But actually it's simpler: with game9_prop
as defined, you can just use
qcTestGengame9 :: TestTree
qcTestGengame9 = QC.testProperty "Better gen rate" game9_prop
Upvotes: 2