diff options
author | chriseth <c@ethdev.com> | 2016-05-08 21:22:54 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-05-09 16:52:23 +0800 |
commit | a927efb1513e31cfa9130458b4ea40d89e283b17 (patch) | |
tree | cdf13fa91e02ebd9d0454b47f8f07fdf4eb877b0 /test/libsolidity | |
parent | 9e36bdda8a9552f1885e0a63a85db588623b39b2 (diff) | |
download | dexon-solidity-a927efb1513e31cfa9130458b4ea40d89e283b17.tar.gz dexon-solidity-a927efb1513e31cfa9130458b4ea40d89e283b17.tar.zst dexon-solidity-a927efb1513e31cfa9130458b4ea40d89e283b17.zip |
Correctly use not/bnot/iszero.
A long time ago, some opcodes were renamed. Now we should only have
not (bitwise negation) and iszero (logical negation).
Diffstat (limited to 'test/libsolidity')
-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 9df64cdc..307dc9a1 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -6735,6 +6735,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() } |