From 47925bc14e80d0c33c491dabc3c3dd3ea787b63c Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 28 Apr 2017 14:33:52 +0100 Subject: Parse for statement in assembly parser / printer --- test/libsolidity/InlineAssembly.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/libsolidity') 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}"); -- cgit