diff options
author | chriseth <c@ethdev.com> | 2017-02-15 01:14:40 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-03-03 22:41:01 +0800 |
commit | fd62adebf3e594298c171e43e78153dbefc42759 (patch) | |
tree | a5faf95dd7e7223c9a487bc46e6aa5a54e685b0a /test | |
parent | 6bfd894f46d12f78e2ea49a58f96763a077bcf49 (diff) | |
download | dexon-solidity-fd62adebf3e594298c171e43e78153dbefc42759.tar.gz dexon-solidity-fd62adebf3e594298c171e43e78153dbefc42759.tar.zst dexon-solidity-fd62adebf3e594298c171e43e78153dbefc42759.zip |
Tests for labels with stack information.
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/InlineAssembly.cpp | 10 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 27 |
2 files changed, 37 insertions, 0 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 9035599b..824fce95 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -200,6 +200,11 @@ BOOST_AUTO_TEST_CASE(blocks) BOOST_CHECK(successParse("{ let x := 7 { let y := 3 } { let z := 2 } }")); } +BOOST_AUTO_TEST_CASE(labels_with_stack_info) +{ + BOOST_CHECK(successParse("{ x[-1]: y[a]: z[d, e]: h[100]: g[]: }")); +} + BOOST_AUTO_TEST_CASE(function_definitions) { BOOST_CHECK(successParse("{ function f() { } function g(a) -> (x) { } }")); @@ -244,6 +249,11 @@ BOOST_AUTO_TEST_CASE(print_label) parsePrintCompare("{\n loop:\n jump(loop)\n}"); } +BOOST_AUTO_TEST_CASE(print_label_with_stack) +{ + parsePrintCompare("{\n loop[x, y]:\n other[-2]:\n third[10]:\n}"); +} + BOOST_AUTO_TEST_CASE(print_assignments) { parsePrintCompare("{\n let x := mul(2, 3)\n 7\n =: x\n x := add(1, 2)\n}"); diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index cb0cc168..d2028344 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7418,6 +7418,33 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_access) BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(10))); } +BOOST_AUTO_TEST_CASE(inline_assembly_labels_with_stack_info) +{ + char const* sourceCode = R"( + contract C { + function f(uint y) { + assembly { + y 7 + jump(fun) + exit[-1]: + y add + 0 mstore + return(0, 0x20) + fun: + { + entry[a, b]: + a := div(a, b) + pop + jump(exit) + } + } + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f(uint256)", u256(15)) == encodeArgs(15 / 7 + 15)); +} + BOOST_AUTO_TEST_CASE(index_access_with_type_conversion) { // Test for a bug where higher order bits cleanup was not done for array index access. |