diff options
author | chriseth <c@ethdev.com> | 2016-05-14 06:58:55 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-05-14 06:58:55 +0800 |
commit | 4b445b898e49c79f4f0ad80aa656ee33ca5b0ebc (patch) | |
tree | 78374c9e93450f5a55a62f7b00e08b58a58574a4 /test | |
parent | 902f1458c61c20299d9d29480e2f73bd3125bb81 (diff) | |
parent | a927efb1513e31cfa9130458b4ea40d89e283b17 (diff) | |
download | dexon-solidity-4b445b898e49c79f4f0ad80aa656ee33ca5b0ebc.tar.gz dexon-solidity-4b445b898e49c79f4f0ad80aa656ee33ca5b0ebc.tar.zst dexon-solidity-4b445b898e49c79f4f0ad80aa656ee33ca5b0ebc.zip |
Merge pull request #546 from chriseth/fixiszero
Correctly use not/bnot/iszero.
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index de428f96..43bdc5a9 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -6736,6 +6736,26 @@ BOOST_AUTO_TEST_CASE(internal_library_function_return_var_size) BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(2))); } +BOOST_AUTO_TEST_CASE(iszero_bnot_correct) +{ + // A long time ago, some opcodes were renamed, which involved the opcodes + // "iszero" and "not". + char const* sourceCode = R"( + contract C { + function f() returns (bool) { + bytes32 x = 1; + assembly { x := not(x) } + if (x != ~bytes32(1)) return false; + assembly { x := iszero(x) } + if (x != bytes32(0)) return false; + return true; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(true)); +} + BOOST_AUTO_TEST_SUITE_END() } |