diff options
author | Yann Herklotz <git@ymhg.org> | 2019-05-13 20:50:01 +0100 |
---|---|---|
committer | Yann Herklotz <git@ymhg.org> | 2019-05-13 20:50:01 +0100 |
commit | 76e9b994258d9af87868ba9f420db4ee1c29de67 (patch) | |
tree | f11b3729582a21ea31555a9106d2190e180e2ce9 /test/Parser.hs | |
parent | 3ddfc0111566113b3ec15725cb5ced6dea531a3a (diff) | |
download | verismith-76e9b994258d9af87868ba9f420db4ee1c29de67.tar.gz verismith-76e9b994258d9af87868ba9f420db4ee1c29de67.zip |
Format with brittany
Diffstat (limited to 'test/Parser.hs')
-rw-r--r-- | test/Parser.hs | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/test/Parser.hs b/test/Parser.hs index 40a8f30..03cc3a6 100644 --- a/test/Parser.hs +++ b/test/Parser.hs @@ -71,59 +71,60 @@ parserIdempotent = Hog.property $ do p sv === (p . p) sv where vshow = showT . GenVerilog - p sv = - either (\x -> showT x <> "\n" <> sv) vshow $ parseVerilog "idempotent_test" sv + p sv = either (\x -> showT x <> "\n" <> sv) vshow + $ parseVerilog "idempotent_test" sv parserTests :: TestTree -parserTests = testGroup "Parser properties" - [ testProperty "Input Mod" parserInputMod - , testProperty "Input" parserInput +parserTests = testGroup + "Parser properties" + [ testProperty "Input Mod" parserInputMod + , testProperty "Input" parserInput , testProperty "Idempotence Mod" parserIdempotentMod - , testProperty "Idempotence" parserIdempotent + , testProperty "Idempotence" parserIdempotent ] testParse :: (Eq a, Show a) => Parser a -> String -> String -> a -> TestTree -testParse p name input golden = testCase name $ - case parse p "testcase" (alexScanTokens input) of - Left e -> assertFailure $ show e +testParse p name input golden = + testCase name $ case parse p "testcase" (alexScanTokens input) of + Left e -> assertFailure $ show e Right result -> golden @=? result testParseFail :: (Eq a, Show a) => Parser a -> String -> String -> TestTree -testParseFail p name input = testCase name $ - case parse p "testcase" (alexScanTokens input) of - Left _ -> return () +testParseFail p name input = + testCase name $ case parse p "testcase" (alexScanTokens input) of + Left _ -> return () Right _ -> assertFailure "Parse incorrectly succeeded" parseEventUnit :: TestTree -parseEventUnit = - testGroup "Event" +parseEventUnit = testGroup + "Event" [ testFailure "No empty event" "@()" - , test "@*" EAll + , test "@*" EAll , test "@(*)" EAll , test "@(posedge clk)" $ EPosEdge "clk" , test "@(negedge clk)" $ ENegEdge "clk" , test "@(wire1)" $ EId "wire1" - , test "@(a or b or c or d)" $ EOr (EId "a") (EOr (EId "b") (EOr (EId "c") (EId "d"))) - , test "@(a, b, c, d)" $ EComb (EId "a") (EComb (EId "b") (EComb (EId "c") (EId "d"))) - , test "@(posedge a or negedge b or c or d)" $ EOr (EPosEdge "a") (EOr (ENegEdge "b") (EOr (EId "c") (EId "d"))) + , test "@(a or b or c or d)" + $ EOr (EId "a") (EOr (EId "b") (EOr (EId "c") (EId "d"))) + , test "@(a, b, c, d)" + $ EComb (EId "a") (EComb (EId "b") (EComb (EId "c") (EId "d"))) + , test "@(posedge a or negedge b or c or d)" + $ EOr (EPosEdge "a") (EOr (ENegEdge "b") (EOr (EId "c") (EId "d"))) ] - where - test a = testParse parseEvent ("Test " <> a) a - testFailure = testParseFail parseEvent + where + test a = testParse parseEvent ("Test " <> a) a + testFailure = testParseFail parseEvent parseAlwaysUnit :: TestTree -parseAlwaysUnit = - testGroup "Always" +parseAlwaysUnit = testGroup + "Always" [ test "Empty" "always begin end" $ Always (SeqBlock []) - , test "Empty with event @*" "always @* begin end" $ Always (EventCtrl EAll (Just (SeqBlock []))) - , test "Empty with event @(posedge clk)" "always @(posedge clk) begin end" $ Always (EventCtrl (EPosEdge "clk") (Just (SeqBlock []))) + , test "Empty with event @*" "always @* begin end" + $ Always (EventCtrl EAll (Just (SeqBlock []))) + , test "Empty with event @(posedge clk)" "always @(posedge clk) begin end" + $ Always (EventCtrl (EPosEdge "clk") (Just (SeqBlock []))) ] - where - test = testParse parseModItem + where test = testParse parseModItem parseUnitTests :: TestTree -parseUnitTests = - testGroup "Parser unit" - [ parseEventUnit - , parseAlwaysUnit - ] +parseUnitTests = testGroup "Parser unit" [parseEventUnit, parseAlwaysUnit] |