Test for embedded functions.

This commit is contained in:
chriseth 2017-06-01 17:59:29 +02:00
parent 0185f3cbf6
commit b098b363b5
2 changed files with 32 additions and 0 deletions

View File

@ -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 {} }"));

View File

@ -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"(