aboutsummaryrefslogtreecommitdiff
path: root/test/Language.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-09-11 16:42:01 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-09-11 16:42:01 +0100
commitfe408149b91b9afe7aaccdbd17e6c665494f8433 (patch)
treef43b34184eaf11506218098305a461ad8496e6cd /test/Language.hs
parent5f5724b0b3785eae99dacc7336b1f4bd9536ef08 (diff)
downloadmicro-lang-hs-fe408149b91b9afe7aaccdbd17e6c665494f8433.tar.gz
micro-lang-hs-fe408149b91b9afe7aaccdbd17e6c665494f8433.zip
Fixed constant folding in function body and return
Diffstat (limited to 'test/Language.hs')
-rw-r--r--test/Language.hs11
1 files changed, 11 insertions, 0 deletions
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,