diff options
Diffstat (limited to 'test/libjulia/Parser.cpp')
-rw-r--r-- | test/libjulia/Parser.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp index f8c1aa4d..9aa325a4 100644 --- a/test/libjulia/Parser.cpp +++ b/test/libjulia/Parser.cpp @@ -269,6 +269,21 @@ BOOST_AUTO_TEST_CASE(multiple_assignment) BOOST_CHECK(successParse(text)); } +BOOST_AUTO_TEST_CASE(if_statement) +{ + BOOST_CHECK(successParse("{ if true:bool {} }")); + BOOST_CHECK(successParse("{ if false:bool { let x:u256 := 3:u256 } }")); + BOOST_CHECK(successParse("{ function f() -> x:bool {} if f() { let b:bool := f() } }")); +} + +BOOST_AUTO_TEST_CASE(if_statement_invalid) +{ + CHECK_ERROR("{ if let x:u256 {} }", ParserError, "Literal or identifier expected."); + CHECK_ERROR("{ if true:bool let x:u256 := 3:u256 }", ParserError, "Expected token LBrace"); + // TODO change this to an error once we check types. + BOOST_CHECK(successParse("{ if 42:u256 { } }")); +} + BOOST_AUTO_TEST_SUITE_END() } |