aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2019-01-20 16:49:17 +0000
committerYann Herklotz <ymherklotz@gmail.com>2019-01-20 16:49:17 +0000
commitd60fc9c882f6ce668123fbfbfd9a0f02dd832f7b (patch)
tree981c9443c8d919b0bc58abbfb8d617223eb99a9f /test
parent8cfacbac3bb16fc0294e6eaf7c7b16c238c58d73 (diff)
downloadverismith-d60fc9c882f6ce668123fbfbfd9a0f02dd832f7b.tar.gz
verismith-d60fc9c882f6ce668123fbfbfd9a0f02dd832f7b.zip
Prettify files
Diffstat (limited to 'test')
-rw-r--r--test/Property.hs16
-rw-r--r--test/Unit.hs95
2 files changed, 76 insertions, 35 deletions
diff --git a/test/Property.hs b/test/Property.hs
index 80c6f68..c6ca390 100644
--- a/test/Property.hs
+++ b/test/Property.hs
@@ -1,4 +1,7 @@
-module Property (propertyTests) where
+module Property
+ ( propertyTests
+ )
+where
import qualified Data.Graph.Inductive as G
import Data.Graph.Inductive.PatriciaTree (Gr)
@@ -19,16 +22,11 @@ instance QC.Arbitrary TestGraph where
instance QC.Arbitrary AltTestGraph where
arbitrary = AltTestGraph <$> QC.resize 100 V.randomDAG
-simpleGraph = QC.testProperty "simple graph generation check" $
- \graph -> simp graph
+simpleGraph = QC.testProperty "simple graph generation check" $ \graph -> simp graph
where simp = G.isSimple . getGraph
-simpleAltGraph = QC.testProperty "simple alternative graph generation check" $
- \graph -> simp graph
+simpleAltGraph = QC.testProperty "simple alternative graph generation check" $ \graph -> simp graph
where simp = G.isSimple . getAltGraph
propertyTests :: TestTree
-propertyTests = testGroup "Property Tests"
- [ simpleGraph
- , simpleAltGraph
- ]
+propertyTests = testGroup "Property Tests" [simpleGraph, simpleAltGraph]
diff --git a/test/Unit.hs b/test/Unit.hs
index 8bcc702..a72e188 100644
--- a/test/Unit.hs
+++ b/test/Unit.hs
@@ -1,4 +1,7 @@
-module Unit (unitTests) where
+module Unit
+ ( unitTests
+ )
+where
import Control.Lens
import qualified Data.Graph.Inductive as G
@@ -8,35 +11,75 @@ import Test.Tasty
import Test.Tasty.HUnit
import VeriFuzz
-unitTests = testGroup "Unit tests"
- [ testCase "Transformation of AST" $
- assertEqual "Successful transformation" transformExpectedResult
+unitTests = testGroup
+ "Unit tests"
+ [ testCase "Transformation of AST" $ assertEqual
+ "Successful transformation"
+ transformExpectedResult
(transformOf traverseExpr trans transformTestData)
]
transformTestData :: Expr
-transformTestData = BinOp (BinOp (BinOp (Id "id1") BinAnd (Id "id2")) BinAnd
- (BinOp (Id "id1") BinAnd (Id "id2"))) BinAnd
- (BinOp (BinOp (BinOp (Id "id1") BinAnd (Id "id2")) BinAnd
- (BinOp (Id "id1") BinAnd (BinOp (BinOp (Id "id1") BinAnd (Id "id2")) BinAnd
- (BinOp (Id "id1") BinAnd (Id "id2"))))) 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"]))
+transformTestData = BinOp
+ (BinOp (BinOp (Id "id1") BinAnd (Id "id2")) BinAnd (BinOp (Id "id1") BinAnd (Id "id2")))
+ BinAnd
+ (BinOp
+ (BinOp
+ (BinOp (Id "id1") BinAnd (Id "id2"))
+ BinAnd
+ (BinOp
+ (Id "id1")
+ BinAnd
+ (BinOp (BinOp (Id "id1") BinAnd (Id "id2")) BinAnd (BinOp (Id "id1") BinAnd (Id "id2")))
+ )
+ )
+ 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"
+ ]
+ )
+ )
transformExpectedResult :: Expr
-transformExpectedResult = BinOp (BinOp (BinOp (Id "id1") BinAnd (Id "Replaced")) BinAnd
- (BinOp (Id "id1") BinAnd (Id "Replaced"))) BinAnd
- (BinOp (BinOp (BinOp (Id "id1") BinAnd (Id "Replaced")) BinAnd
- (BinOp (Id "id1") BinAnd (BinOp (BinOp (Id "id1") BinAnd (Id "Replaced")) BinAnd
- (BinOp (Id "id1") BinAnd (Id "Replaced"))))) 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"]))
+transformExpectedResult = BinOp
+ (BinOp (BinOp (Id "id1") BinAnd (Id "Replaced")) BinAnd (BinOp (Id "id1") BinAnd (Id "Replaced")))
+ BinAnd
+ (BinOp
+ (BinOp
+ (BinOp (Id "id1") BinAnd (Id "Replaced"))
+ BinAnd
+ (BinOp
+ (Id "id1")
+ BinAnd
+ (BinOp (BinOp (Id "id1") BinAnd (Id "Replaced"))
+ BinAnd
+ (BinOp (Id "id1") BinAnd (Id "Replaced"))
+ )
+ )
+ )
+ 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"
+ ]
+ )
+ )
-trans e =
- case e of
- Id id -> if id == Identifier "id2" then
- Id $ Identifier "Replaced"
- else Id id
- _ -> e
+trans e = case e of
+ Id id -> if id == Identifier "id2" then Id $ Identifier "Replaced" else Id id
+ _ -> e