From 005885ac949262279441d7ed216fcb1d4d5c384c Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Wed, 1 Feb 2023 17:29:24 +0100 Subject: [PATCH] add tests --- .../Transformation/LambdaLetRecLifting.hs | 3 +++ test/Core/Transformation/Lifting.hs | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs b/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs index ca017989bb..7a6fc7d1be 100644 --- a/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs +++ b/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs @@ -185,3 +185,6 @@ nodeIsLetRecLifted = not . hasLetRecs isLifted :: InfoTable -> Bool isLifted = all nodeIsLifted . (^. identContext) + +isLetRecLifted :: InfoTable -> Bool +isLetRecLifted = all nodeIsLetRecLifted . (^. identContext) diff --git a/test/Core/Transformation/Lifting.hs b/test/Core/Transformation/Lifting.hs index dda4b0bee8..53e7c6eaa8 100644 --- a/test/Core/Transformation/Lifting.hs +++ b/test/Core/Transformation/Lifting.hs @@ -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 = @@ -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]