aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-01 23:59:29 +0800
committerchriseth <chris@ethereum.org>2017-06-08 21:52:45 +0800
commitb098b363b55a687542c97c8f35f65d0eb08eb44a (patch)
treed68d39676a804edd311771672ce85b807e6564f1 /test
parent0185f3cbf6aae954d8c59a556af0e150850022bc (diff)
downloaddexon-solidity-b098b363b55a687542c97c8f35f65d0eb08eb44a.tar
dexon-solidity-b098b363b55a687542c97c8f35f65d0eb08eb44a.tar.gz
dexon-solidity-b098b363b55a687542c97c8f35f65d0eb08eb44a.tar.bz2
dexon-solidity-b098b363b55a687542c97c8f35f65d0eb08eb44a.tar.lz
dexon-solidity-b098b363b55a687542c97c8f35f65d0eb08eb44a.tar.xz
dexon-solidity-b098b363b55a687542c97c8f35f65d0eb08eb44a.tar.zst
dexon-solidity-b098b363b55a687542c97c8f35f65d0eb08eb44a.zip
Test for embedded functions.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/InlineAssembly.cpp5
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp27
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"(