From 88d9c4a76e27ddee2170bb21e90e0f0fcf77b44c Mon Sep 17 00:00:00 2001 From: defanor Date: Mon, 4 Dec 2017 19:14:06 +0300 Subject: Introduce the omitNamedOptions option It is nice to omit them, but may lead to ambiguity -- so better to provide a safer option. --- test/Test.hs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'test') 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 -- cgit v1.2.3