diff options
-rw-r--r-- | test/libsolidity/InlineAssembly.cpp | 5 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 4de2ea81..e9e310d0 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -509,6 +509,11 @@ BOOST_AUTO_TEST_CASE(function_calls) BOOST_CHECK(successAssemble("{ let r := 2 function f() -> x, y { x := 1 y := 2} let a, b := f() b := r }")); } +BOOST_AUTO_TEST_CASE(embedded_functions) +{ + BOOST_CHECK(successAssemble("{ function f(r, s) -> x { function g(a) -> b { } x := g(2) } let x := f(2, 3) }")); +} + BOOST_AUTO_TEST_CASE(switch_statement) { BOOST_CHECK(successAssemble("{ switch 1 default {} }")); diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 212c5111..52ce65f1 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7612,6 +7612,33 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_call2) BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(1), u256(2), u256(7), u256(0x10))); } +BOOST_AUTO_TEST_CASE(inline_assembly_embedded_function_call) +{ + char const* sourceCode = R"( + contract C { + function f() { + assembly { + let d := 0x10 + function asmfun(a, b, c) -> x, y, z { + x := g(a) + function g(r) -> s { s := mul(r, r) } + y := g(b) + z := 7 + } + let a1, b1, c1 := asmfun(1, 2, 3) + mstore(0x00, a1) + mstore(0x20, b1) + mstore(0x40, c1) + mstore(0x60, d) + return(0, 0x80) + } + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(1), u256(4), u256(7), u256(0x10))); +} + BOOST_AUTO_TEST_CASE(inline_assembly_switch) { char const* sourceCode = R"( |