diff options
author | chriseth <chris@ethereum.org> | 2016-12-08 23:15:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-08 23:15:35 +0800 |
commit | 84443eb56022cdb236425b99e253d0b142261372 (patch) | |
tree | 4521cefe6c045373644c20b485c0b31c2ee9edd5 /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | e7ff4ac810a44cf3bfd58ee4ff198f136f011e2d (diff) | |
parent | e7760417e83cf9e313c76cdd44f860aeec1b798c (diff) | |
download | dexon-solidity-84443eb56022cdb236425b99e253d0b142261372.tar.gz dexon-solidity-84443eb56022cdb236425b99e253d0b142261372.tar.zst dexon-solidity-84443eb56022cdb236425b99e253d0b142261372.zip |
Merge pull request #1351 from ethereum/truncate_bit
Truncate a boolean from calldata into one bit
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 aa1eb20a..2df6e9f2 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -4591,6 +4591,34 @@ BOOST_AUTO_TEST_CASE(super_overload) BOOST_CHECK(callContractFunction("h()") == encodeArgs(2)); } +BOOST_AUTO_TEST_CASE(bool_conversion) +{ + char const* sourceCode = R"( + contract C { + function f(bool _b) returns(uint) { + if (_b) + return 1; + else + return 0; + } + function g(bool _in) returns (bool _out) { + _out = _in; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f(bool)", 0) == encodeArgs(0)); + BOOST_CHECK(callContractFunction("f(bool)", 1) == encodeArgs(1)); + BOOST_CHECK(callContractFunction("f(bool)", 2) == encodeArgs(1)); + BOOST_CHECK(callContractFunction("f(bool)", 3) == encodeArgs(1)); + BOOST_CHECK(callContractFunction("f(bool)", 255) == encodeArgs(1)); + BOOST_CHECK(callContractFunction("g(bool)", 0) == encodeArgs(0)); + BOOST_CHECK(callContractFunction("g(bool)", 1) == encodeArgs(1)); + BOOST_CHECK(callContractFunction("g(bool)", 2) == encodeArgs(1)); + BOOST_CHECK(callContractFunction("g(bool)", 3) == encodeArgs(1)); + BOOST_CHECK(callContractFunction("g(bool)", 255) == encodeArgs(1)); +} + BOOST_AUTO_TEST_CASE(packed_storage_signed) { char const* sourceCode = R"( |