summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-04 19:14:06 +0300
committerdefanor <defanor@uberspace.net>2017-12-04 19:14:06 +0300
commit88d9c4a76e27ddee2170bb21e90e0f0fcf77b44c (patch)
tree9d961f8fc78132d652edfc0c037cfb2ec0d74bda /test
parent0da83fbee2a242d78fa835b011c09839ac2eacda (diff)
Introduce the omitNamedOptions option
It is nice to omit them, but may lead to ambiguity -- so better to provide a safer option.
Diffstat (limited to 'test')
-rw-r--r--test/Test.hs22
1 files changed, 12 insertions, 10 deletions
diff --git a/test/Test.hs b/test/Test.hs
index d5860d4..ffcae8e 100644
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -106,14 +106,14 @@ instance ToArgs RecordStrings
instance Arbitrary RecordStrings where arbitrary = genericArbitraryU
printAndParse :: (ArgParser a, ToArgs a, Eq a)
- => Modifiers -> Proxy a -> a -> Bool
+ => Options -> Proxy a -> a -> Bool
printAndParse m _ r = Right r == fromArgs m (toArgs m r)
mkTest :: (ArgParser a, ToArgs a, Eq a, Show a, Arbitrary a)
- => Modifiers -> Proxy a -> String -> TestTree
+ => Options -> Proxy a -> String -> TestTree
mkTest m p n = QC.testProperty n (printAndParse m p)
-idEqToAndFrom :: Modifiers -> TestTree
+idEqToAndFrom :: Options -> TestTree
idEqToAndFrom m = testGroup "id == parse . print"
[ mkTest m (Proxy :: Proxy Basic) "Basic"
, mkTest m (Proxy :: Proxy WithLists) "WithLists"
@@ -134,17 +134,19 @@ idEqToAndFrom m = testGroup "id == parse . print"
, mkTest m (Proxy :: Proxy RecordStrings) "RecordStrings"
]
-variousModifiers :: (Modifiers -> TestTree) -> TestTree
-variousModifiers tt = testGroup "Various modifiers"
- [ testGroup "alwaysUseSelName = True"
- [tt defMod { alwaysUseSelName = True }]
- , testGroup "alwaysUseSelName = False"
- [tt defMod { alwaysUseSelName = False }]
+variousOptions :: (Options -> TestTree) -> TestTree
+variousOptions tt = testGroup "Various modifiers"
+ [ testGroup (concat [ "alwaysUseSelName = ", show ausn
+ , ", omitNamedOptions = ", show ono])
+ [tt defOpt { alwaysUseSelName = ausn
+ , omitNamedOptions = ono }]
+ | ausn <- [True, False]
+ , ono <- [True, False]
]
qcProps :: TestTree
qcProps = testGroup "Quickcheck properties"
- [ variousModifiers idEqToAndFrom ]
+ [ variousOptions idEqToAndFrom ]
main :: IO ()
main = travisTestReporter defaultConfig [] qcProps