From 76e9b994258d9af87868ba9f420db4ee1c29de67 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Mon, 13 May 2019 20:50:01 +0100 Subject: Format with brittany --- test/Doctest.hs | 3 +-- test/Parser.hs | 65 +++++++++++++++++++++++++++++---------------------------- test/Reduce.hs | 16 +++++++------- test/Unit.hs | 56 ++++++++++++++++++++++++------------------------- 4 files changed, 71 insertions(+), 69 deletions(-) (limited to 'test') diff --git a/test/Doctest.hs b/test/Doctest.hs index 1b899c3..7463dfe 100644 --- a/test/Doctest.hs +++ b/test/Doctest.hs @@ -4,5 +4,4 @@ import Build_doctests (flags, module_sources, pkgs) import Test.DocTest (doctest) main :: IO () -main = doctest args - where args = flags ++ pkgs ++ module_sources +main = doctest args where args = flags ++ pkgs ++ module_sources 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] diff --git a/test/Reduce.hs b/test/Reduce.hs index cb90824..0cff8f5 100644 --- a/test/Reduce.hs +++ b/test/Reduce.hs @@ -13,7 +13,8 @@ Test reduction. {-# LANGUAGE QuasiQuotes #-} module Reduce - (reduceUnitTests) + ( reduceUnitTests + ) where import Data.List ((\\)) @@ -23,13 +24,11 @@ import VeriFuzz import VeriFuzz.Reduce reduceUnitTests :: TestTree -reduceUnitTests = testGroup "Reducer tests" - [ moduleReducerTest - , modItemReduceTest - , halveStatementsTest - , activeWireTest - ] +reduceUnitTests = testGroup + "Reducer tests" + [moduleReducerTest, modItemReduceTest, halveStatementsTest, activeWireTest] +-- brittany-disable-next-binding activeWireTest :: TestTree activeWireTest = testCase "Active wires" $ do findActiveWires verilog1 \\ ["x", "y", "z", "w"] @?= [] @@ -76,6 +75,7 @@ module top(clk, y, x); endmodule |] +-- brittany-disable-next-binding halveStatementsTest :: TestTree halveStatementsTest = testCase "Statements" $ do GenVerilog <$> halveStatements srcInfo1 @?= golden1 @@ -140,6 +140,7 @@ module top(clk, y, x); endmodule |]) +-- brittany-disable-next-binding modItemReduceTest :: TestTree modItemReduceTest = testCase "Module items" $ do GenVerilog <$> halveModItems srcInfo1 @?= golden1 @@ -175,6 +176,7 @@ module top(y, x); endmodule |]) +-- brittany-disable-next-binding moduleReducerTest :: TestTree moduleReducerTest = testCase "Module reducer" $ do halveModules srcInfo1 @?= golden1 diff --git a/test/Unit.hs b/test/Unit.hs index 013d595..84508c4 100644 --- a/test/Unit.hs +++ b/test/Unit.hs @@ -15,9 +15,9 @@ unitTests :: TestTree unitTests = testGroup "Unit tests" [ testCase "Transformation of AST" $ assertEqual - "Successful transformation" - transformExpectedResult - (transform trans transformTestData) + "Successful transformation" + transformExpectedResult + (transform trans transformTestData) , parseUnitTests , reduceUnitTests ] @@ -43,17 +43,19 @@ transformTestData = BinOp ) ) BinOr - (Concat $ - ( Concat $ - (Concat $ (Id "id1") :| [Id "id2", Id "id2"]) :| - [ Id "id2" - , Id "id2" - , (Concat $ (Id "id2") :| [Id "id2", (Concat $ Id "id1" :| [Id "id2"])]) - , Id "id2" - ] - ) :| [ Id "id1" - , Id "id2" - ] + ( Concat + $ ( Concat + $ (Concat $ (Id "id1") :| [Id "id2", Id "id2"]) + :| [ Id "id2" + , Id "id2" + , ( Concat + $ (Id "id2") + :| [Id "id2", (Concat $ Id "id1" :| [Id "id2"])] + ) + , Id "id2" + ] + ) + :| [Id "id1", Id "id2"] ) ) @@ -78,20 +80,18 @@ transformExpectedResult = BinOp ) ) BinOr - (Concat $ - ( Concat $ - (Concat $ (Id "id1") :| [Id "Replaced", Id "Replaced"]) :| - [ Id "Replaced" - , Id "Replaced" - , Concat $ - Id "Replaced" :| - [ Id "Replaced" - , Concat $ Id "id1" :| [Id "Replaced"] - ] - , Id "Replaced" - ] ) :| [ Id "id1" - , Id "Replaced" - ] + ( Concat + $ ( Concat + $ (Concat $ (Id "id1") :| [Id "Replaced", Id "Replaced"]) + :| [ Id "Replaced" + , Id "Replaced" + , Concat + $ Id "Replaced" + :| [Id "Replaced", Concat $ Id "id1" :| [Id "Replaced"]] + , Id "Replaced" + ] + ) + :| [Id "id1", Id "Replaced"] ) ) -- cgit