aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-09 19:29:28 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-06-16 17:56:21 +0800
commit1b3ba7bc5796e30143763eb8fcca589bd7095edb (patch)
treeac21d6b7396b5aeba1c8e72a3f2fef92a3f8bf6d /test
parent78b49db779376b8ddedc0abb91a82a3384def4f1 (diff)
downloaddexon-solidity-1b3ba7bc5796e30143763eb8fcca589bd7095edb.tar.gz
dexon-solidity-1b3ba7bc5796e30143763eb8fcca589bd7095edb.tar.zst
dexon-solidity-1b3ba7bc5796e30143763eb8fcca589bd7095edb.zip
Some more tests.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/InlineAssembly.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp
index a3339d47..460a2771 100644
--- a/test/libsolidity/InlineAssembly.cpp
+++ b/test/libsolidity/InlineAssembly.cpp
@@ -269,6 +269,7 @@ BOOST_AUTO_TEST_CASE(switch_invalid_expression)
{
CHECK_PARSE_ERROR("{ switch {} default {} }", ParserError, "Literal, identifier or instruction expected.");
CHECK_PARSE_ERROR("{ switch calldatasize default {} }", ParserError, "Instructions are not supported as expressions for switch.");
+ CHECK_PARSE_ERROR("{ switch mstore(1, 1) default {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
}
BOOST_AUTO_TEST_CASE(switch_default_before_case)
@@ -294,13 +295,17 @@ BOOST_AUTO_TEST_CASE(switch_invalid_body)
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_CHECK(successParse("{ for { let i := 1 } lt(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("{ for 1 1 {} {} }", ParserError, "Expected token LBrace got 'Number'");
+ CHECK_PARSE_ERROR("{ for {} 1 1 {} }", ParserError, "Expected token LBrace got 'Number'");
+ CHECK_PARSE_ERROR("{ for {} 1 {} 1 }", ParserError, "Expected token LBrace got 'Number'");
CHECK_PARSE_ERROR("{ 1 2 for {} mul {} {} }", ParserError, "Instructions are not supported as conditions for the for statement.");
+ CHECK_PARSE_ERROR("{ for {} mstore(1, 1) {} {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
}
BOOST_AUTO_TEST_CASE(blocks)
@@ -423,7 +428,7 @@ BOOST_AUTO_TEST_CASE(print_switch)
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}");
+ parsePrintCompare("{\n let ret := 5\n for {\n let i := 1\n }\n lt(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)
@@ -551,6 +556,13 @@ BOOST_AUTO_TEST_CASE(switch_statement)
BOOST_CHECK(successAssemble("{ let a := 2 switch calldataload(0) case 1 { a := 1 } case 2 { a := 5 } }"));
}
+BOOST_AUTO_TEST_CASE(for_statement)
+{
+ BOOST_CHECK(successAssemble("{ for {} 1 {} {} }"));
+ BOOST_CHECK(successAssemble("{ let x := calldatasize() for { let i := 0} lt(i, x) { i := add(i, 1) } { mstore(i, 2) } }"));
+}
+
+
BOOST_AUTO_TEST_CASE(large_constant)
{
auto source = R"({