From fe408149b91b9afe7aaccdbd17e6c665494f8433 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 11 Sep 2022 16:42:01 +0100 Subject: Fixed constant folding in function body and return --- test/Language.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/Language.hs b/test/Language.hs index 9d81733..6e15525 100644 --- a/test/Language.hs +++ b/test/Language.hs @@ -259,6 +259,16 @@ testCase18 = A.Num 16 $ newPos "-" 2 13 ] +testCase19 = + TestLabel "fold constant addition in return" $ + TestCase $ + assertCompileAst + "module main\n\ + \def fn(): u8 { return 1 + 2; }" + [ A.Module "main" $ newPos "-" 1 1, + A.Func "fn" [] (Just $ A.Type "u8") [A.Return (Just $ A.Num 3 $ newPos "-" 2 27) $ newPos "-" 2 16] False False $ newPos "-" 2 1 + ] + -- test errors testCaseE1 = @@ -424,6 +434,7 @@ language = testCase16, testCase17, testCase18, + testCase19, -- errors testCaseE1, testCaseE2, -- cgit v1.2.3