Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Feb 1, 2023
1 parent fa3bf3c commit 005885a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,6 @@ nodeIsLetRecLifted = not . hasLetRecs

isLifted :: InfoTable -> Bool
isLifted = all nodeIsLifted . (^. identContext)

isLetRecLifted :: InfoTable -> Bool
isLetRecLifted = all nodeIsLetRecLifted . (^. identContext)
25 changes: 21 additions & 4 deletions test/Core/Transformation/Lifting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import Core.Transformation.Base
import Juvix.Compiler.Core.Transformation

allTests :: TestTree
allTests = testGroup "Lambda and LetRec lifting" (map liftTest Eval.tests)

pipe :: [TransformationId]
pipe = [LambdaLetRecLifting]
allTests =
testGroup
"Lifting"
[ testGroup "Lambda and LetRec lifting" (map liftTest Eval.tests),
testGroup "Only LetRec lifting" (map letRecLiftTest Eval.tests)
]

liftTest :: Eval.PosTest -> TestTree
liftTest _testEval =
Expand All @@ -19,3 +21,18 @@ liftTest _testEval =
_testAssertion = \i -> unless (isLifted i) (error "not lambda lifted"),
_testEval
}
where
pipe :: [TransformationId]
pipe = [LambdaLetRecLifting]

letRecLiftTest :: Eval.PosTest -> TestTree
letRecLiftTest _testEval =
fromTest
Test
{ _testTransformations = pipe,
_testAssertion = \i -> unless (isLetRecLifted i) (error "not letrec lifted"),
_testEval
}
where
pipe :: [TransformationId]
pipe = [LetRecLifting]

0 comments on commit 005885a

Please sign in to comment.