From 967ae182b0a6852cc37e77cb88ee53a53526f027 Mon Sep 17 00:00:00 2001 From: defanor Date: Mon, 4 Dec 2017 07:28:42 +0300 Subject: Be more strict on record selector name parsing Ambiguity is possible if the parser accepts those optionally, so it should accept them depending on the provided options. --- test/Test.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/Test.hs b/test/Test.hs index a467ceb..d5860d4 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -96,6 +96,14 @@ instance ArgParser RecursiveRecordMaybe2 instance ToArgs RecursiveRecordMaybe2 instance Arbitrary RecursiveRecordMaybe2 where arbitrary = genericArbitraryU +data RecordStrings = RecordStrings + { s1 :: String + , s2 :: String + , s3 :: String + } deriving (Generic, Eq, Show) +instance ArgParser RecordStrings +instance ToArgs RecordStrings +instance Arbitrary RecordStrings where arbitrary = genericArbitraryU printAndParse :: (ArgParser a, ToArgs a, Eq a) => Modifiers -> Proxy a -> a -> Bool @@ -123,14 +131,15 @@ idEqToAndFrom m = testGroup "id == parse . print" , mkTest m (Proxy :: Proxy NestedSum) "NestedSum" , mkTest m (Proxy :: Proxy RecursiveRecordMaybe) "RecursiveRecordMaybe" , mkTest m (Proxy :: Proxy RecursiveRecordMaybe2) "RecursiveRecordMaybe2" + , mkTest m (Proxy :: Proxy RecordStrings) "RecordStrings" ] variousModifiers :: (Modifiers -> TestTree) -> TestTree variousModifiers tt = testGroup "Various modifiers" - [ testGroup "alwaysAddSelName = True" - [tt defMod { alwaysAddSelName = True }] - , testGroup "alwaysAddSelName = False" - [tt defMod { alwaysAddSelName = False }] + [ testGroup "alwaysUseSelName = True" + [tt defMod { alwaysUseSelName = True }] + , testGroup "alwaysUseSelName = False" + [tt defMod { alwaysUseSelName = False }] ] qcProps :: TestTree -- cgit v1.2.3