diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-04-28 21:33:52 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-06-16 17:56:21 +0800 |
commit | 47925bc14e80d0c33c491dabc3c3dd3ea787b63c (patch) | |
tree | 10f0dc08bf0a78a02a921d7fa69449c94d6676a3 /test | |
parent | 54e97d1c34d7c291673e695a991db8df627c503e (diff) | |
download | dexon-solidity-47925bc14e80d0c33c491dabc3c3dd3ea787b63c.tar.gz dexon-solidity-47925bc14e80d0c33c491dabc3c3dd3ea787b63c.tar.zst dexon-solidity-47925bc14e80d0c33c491dabc3c3dd3ea787b63c.zip |
Parse for statement in assembly parser / printer
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/InlineAssembly.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index aae6dacd..a3339d47 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -291,6 +291,18 @@ BOOST_AUTO_TEST_CASE(switch_invalid_body) CHECK_PARSE_ERROR("{ switch 42 case 1 mul case 2 {} default {} }", ParserError, "Expected token LBrace got 'Identifier'"); } +BOOST_AUTO_TEST_CASE(for_statement) +{ + BOOST_CHECK(successParse("{ for {} 1 {} {} }")); + BOOST_CHECK(successParse("{ for { let i := 1 } le(i, 5) { i := add(i, 1) } {} }")); +} + +BOOST_AUTO_TEST_CASE(for_invalid_expression) +{ + CHECK_PARSE_ERROR("{ for {} {} {} {} }", ParserError, "Literal, identifier or instruction expected."); + CHECK_PARSE_ERROR("{ 1 2 for {} mul {} {} }", ParserError, "Instructions are not supported as conditions for the for statement."); +} + BOOST_AUTO_TEST_CASE(blocks) { BOOST_CHECK(successParse("{ let x := 7 { let y := 3 } { let z := 2 } }")); @@ -409,6 +421,11 @@ BOOST_AUTO_TEST_CASE(print_switch) parsePrintCompare("{\n switch 42\n case 1 {\n }\n case 2 {\n }\n default {\n }\n}"); } +BOOST_AUTO_TEST_CASE(print_for) +{ + parsePrintCompare("{\n let ret := 5\n for {\n let i := 1\n }\n le(i, 15)\n {\n i := add(i, 1)\n }\n {\n ret := mul(ret, i)\n }\n}"); +} + BOOST_AUTO_TEST_CASE(function_definitions_multiple_args) { parsePrintCompare("{\n function f(a, d)\n {\n mstore(a, d)\n }\n function g(a, d) -> x, y\n {\n }\n}"); |