Skip to content

Commit 927441d

Browse files
committed
Fixup tests
1 parent f34dfdc commit 927441d

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/Bayeux/Lp.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ table = [ [ prefix "~" Bar ]
105105
]
106106

107107
binary :: Text -> (Lp Text -> Lp Text -> Lp Text) -> Operator Parser (Lp Text)
108-
binary name f = InfixL (f <$ symbol name)
108+
binary name f = InfixR (f <$ symbol name)
109109

110110
prefix :: Text -> (Lp Text -> Lp Text) -> Operator Parser (Lp Text)
111111
prefix name f = Prefix (f <$ symbol name)

test/Main.hs

+13-8
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ main = defaultMain $ testGroup "Bayeux"
2323
, testGroup "Hedgehog" hedgehogTests
2424
]
2525

26-
mkTestCase :: Eq a => Pretty a => (Lp a, Bool, String) -> TestTree
26+
mkTestCase :: (Lp Text, Bool, String) -> TestTree
2727
mkTestCase (lp, expected, description) =
2828
let display = unwords [description, T.unpack $ prettyLp lp]
29-
in testCase display $ prove lp @?= expected
29+
in testGroup display
30+
[ testCase "prove" $ prove lp @?= expected
31+
, testCase "parse . pretty" $ (parseMaybe parseLp . prettyLp) lp @?= Just (lp)
32+
]
3033

31-
smullyan
32-
:: [(Lp String, Bool, String)]
34+
smullyan :: [(Lp Text, Bool, String)]
3335
smullyan =
3436
[ ( ("p" ==> ("q" ==> "r")) ==> (("p" ==> "q") ==> ("p" ==> "r"))
3537
, True
@@ -87,12 +89,15 @@ smullyan =
8789

8890
parseTests :: [TestTree]
8991
parseTests =
90-
[ testCase "" $ parseMaybe parseLp "a" @?= Just "a"
91-
, testCase "" $ parseMaybe parseLp "~a" @?= Just "~a"
92-
, testGroup "Smullyan parse after pretty" $ mkParsePrettyTestCase <$> smullyan
92+
[ tc "a" "a"
93+
, tc "~a" "~a"
94+
, tc "a => b => c" $ "a" ==> "b" ==> "c"
95+
, tc "a => (b => c)" $ "a" ==> "b" ==> "c"
96+
, tc "(a => b) => c" $ ("a" ==> "b") ==> "c"
97+
, tc "~a \\/ ~b" $ "~a" \/ "~b"
9398
]
9499
where
95-
mkParsePrettyTestCase (lp, _, _) = testCase (T.unpack $ prettyLp lp) $ (parseMaybe parseLp . prettyLp) lp @?= Just (fromString <$> lp)
100+
tc t lp = testCase (T.unpack t) $ parseMaybe parseLp t @?= Just lp
96101

97102
genName :: MonadGen m => m Text
98103
genName = Gen.text (Range.linear 1 10) Gen.alphaNum

0 commit comments

Comments
 (0)