aboutsummaryrefslogtreecommitdiffstats
path: root/test/Unit.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Unit.hs')
-rw-r--r--test/Unit.hs125
1 files changed, 65 insertions, 60 deletions
diff --git a/test/Unit.hs b/test/Unit.hs
index 404c899..d911d2f 100644
--- a/test/Unit.hs
+++ b/test/Unit.hs
@@ -1,6 +1,6 @@
module Unit
- ( unitTests
- )
+ ( unitTests
+ )
where
import Control.Lens
@@ -10,75 +10,80 @@ import VeriFuzz
unitTests :: TestTree
unitTests = testGroup
- "Unit tests"
- [ testCase "Transformation of AST" $ assertEqual
- "Successful transformation"
- transformExpectedResult
- (transform trans transformTestData)
- ]
+ "Unit tests"
+ [ testCase "Transformation of AST" $ assertEqual "Successful transformation"
+ transformExpectedResult
+ (transform 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 (Id "id2")))
+ BinAnd
(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"
- ]
+ (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 (Id "Replaced"))
+ )
+ BinAnd
(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"))
+ (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"
+ ]
)
- )
- )
- 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 :: Expr -> Expr
trans e = case e of
- Id i -> if i == Identifier "id2" then Id $ Identifier "Replaced" else Id i
- _ -> e
+ Id i -> if i == Identifier "id2" then Id $ Identifier "Replaced" else Id i
+ _ -> e