diff options
author | chriseth <chris@ethereum.org> | 2018-02-28 00:06:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-28 00:06:10 +0800 |
commit | 908b46e9a7f56a06c76db9e702fb9b25d8b0d344 (patch) | |
tree | 47594aa2e1c58a14557263f04199f01421622106 /test/libsolidity/SolidityExpressionCompiler.cpp | |
parent | 6d8dee586c592b3ed34143b0e4c6cba3b704fa84 (diff) | |
parent | d64aa0eaad50741896020d31c0c93b64c3f03bc1 (diff) | |
download | dexon-solidity-908b46e9a7f56a06c76db9e702fb9b25d8b0d344.tar dexon-solidity-908b46e9a7f56a06c76db9e702fb9b25d8b0d344.tar.gz dexon-solidity-908b46e9a7f56a06c76db9e702fb9b25d8b0d344.tar.bz2 dexon-solidity-908b46e9a7f56a06c76db9e702fb9b25d8b0d344.tar.lz dexon-solidity-908b46e9a7f56a06c76db9e702fb9b25d8b0d344.tar.xz dexon-solidity-908b46e9a7f56a06c76db9e702fb9b25d8b0d344.tar.zst dexon-solidity-908b46e9a7f56a06c76db9e702fb9b25d8b0d344.zip |
Merge pull request #3476 from ethereum/scoping
C99/C++ scoping rules
Diffstat (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp')
-rw-r--r-- | test/libsolidity/SolidityExpressionCompiler.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 67747386..e2a0c3cd 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -322,10 +322,10 @@ BOOST_AUTO_TEST_CASE(arithmetics) { char const* sourceCode = R"( contract test { - function f(uint y) { var x = ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); } + function f(uint y) { ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); } } )"; - bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}}); + bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes expectation({byte(Instruction::PUSH1), 0x1, byte(Instruction::PUSH1), 0x2, byte(Instruction::PUSH1), 0x3, @@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(arithmetics) byte(Instruction::PUSH1), 0x6, byte(Instruction::PUSH1), 0x7, byte(Instruction::PUSH1), 0x8, - byte(Instruction::DUP10), + byte(Instruction::DUP9), byte(Instruction::XOR), byte(Instruction::AND), byte(Instruction::OR), @@ -364,13 +364,13 @@ BOOST_AUTO_TEST_CASE(unary_operators) { char const* sourceCode = R"( contract test { - function f(int y) { var x = !(~+- y == 2); } + function f(int y) { !(~+- y == 2); } } )"; - bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}}); + bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes expectation({byte(Instruction::PUSH1), 0x2, - byte(Instruction::DUP3), + byte(Instruction::DUP2), byte(Instruction::PUSH1), 0x0, byte(Instruction::SUB), byte(Instruction::NOT), @@ -383,7 +383,7 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec) { char const* sourceCode = R"( contract test { - function f(uint a) { var x = --a ^ (a-- ^ (++a ^ a++)); } + function f(uint a) returns (uint x) { x = --a ^ (a-- ^ (++a ^ a++)); } } )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}}); @@ -426,7 +426,10 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec) byte(Instruction::POP), // second ++ // Stack here: a x a^(a+2)^(a+2) byte(Instruction::DUP3), // will change - byte(Instruction::XOR)}); + byte(Instruction::XOR), + byte(Instruction::SWAP1), + byte(Instruction::POP), + byte(Instruction::DUP1)}); // Stack here: a x a^(a+2)^(a+2)^a BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } |