diff options
author | chriseth <chris@ethereum.org> | 2018-02-27 04:14:20 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-02-27 19:41:32 +0800 |
commit | d64aa0eaad50741896020d31c0c93b64c3f03bc1 (patch) | |
tree | 189ad4cfbc487987aef0aaaea68d2944c3ea8b74 /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | 6391a36a6c71c1e8177358bc3832e32504e73111 (diff) | |
download | dexon-solidity-d64aa0eaad50741896020d31c0c93b64c3f03bc1.tar.gz dexon-solidity-d64aa0eaad50741896020d31c0c93b64c3f03bc1.tar.zst dexon-solidity-d64aa0eaad50741896020d31c0c93b64c3f03bc1.zip |
Some more scoping tests.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 7bae3cd6..c352a2c2 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -298,10 +298,38 @@ BOOST_AUTO_TEST_CASE(C99_scoping_activation) } return x; } + function g() pure public returns (uint x) { + x = 7; + { + x = 3; + uint x; + return x; // This returns the new variable, i.e. 0 + } + } + function h() pure public returns (uint x, uint a, uint b) { + x = 7; + { + x = 3; + a = x; // This should read from the outer + uint x = 4; + b = x; + } + } + function i() pure public returns (uint x, uint a) { + x = 7; + { + x = 3; + uint x = x; // This should read from the outer and assign to the inner + a = x; + } + } } )"; compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f()"), encodeArgs(3)); + ABI_CHECK(callContractFunction("g()"), encodeArgs(0)); + ABI_CHECK(callContractFunction("h()"), encodeArgs(3, 3, 4)); + ABI_CHECK(callContractFunction("i()"), encodeArgs(3, 3)); } BOOST_AUTO_TEST_CASE(recursive_calls) |