From fcf8a0771a090777774e96082118d9bdf5191052 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 16 Aug 2022 07:59:36 +0100 Subject: Return test --- test/Language.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/Language.hs b/test/Language.hs index ea387d8..a9da577 100644 --- a/test/Language.hs +++ b/test/Language.hs @@ -34,9 +34,10 @@ testCase = TestCase $ do assertAst "parse a function with return value" "module main\n\ - \def fn(): u8 { }" + \def fn(): u8 {\n\ + \return 1; }" [ A.Module "main" $ newPos "test" 1 1, - A.Func "fn" [] (Just $ A.Type "u8") [] False False $ newPos "test" 2 1 + A.Func "fn" [] (Just $ A.Type "u8") [A.Return (Just $ A.Num 1 $ newPos "test" 3 8) $ newPos "test" 3 1] False False $ newPos "test" 2 1 ] assertAst "parse a function call" @@ -56,5 +57,13 @@ testCase = TestCase $ do A.Func "fn" [("a", A.Type "u8", newPos "test" 2 8)] Nothing [] False False $ newPos "test" 2 1, A.Call (A.Var "fn" $ newPos "test" 3 1) [A.Num 10 $ newPos "test" 3 4] $ newPos "test" 3 1 ] + assertAst + "parse empty return on a function" + "module main\n\ + \def fn() {\n\ + \return; }" + [ A.Module "main" $ newPos "test" 1 1, + A.Func "fn" [] Nothing [A.Return Nothing $ newPos "test" 3 1] False False $ newPos "test" 2 1 + ] language = [testCase] -- cgit v1.2.3