aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-11-10 18:44:31 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-12-01 00:40:34 +0800
commitb16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee (patch)
tree75647c426ca0eff8c9756c665cde96c4533766e2 /test
parentac357d12252ceb113a823a400418a59a94521c71 (diff)
downloaddexon-solidity-b16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee.tar
dexon-solidity-b16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee.tar.gz
dexon-solidity-b16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee.tar.bz2
dexon-solidity-b16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee.tar.lz
dexon-solidity-b16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee.tar.xz
dexon-solidity-b16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee.tar.zst
dexon-solidity-b16cdbb57e2f3bdc99b2cf367e40a7f78b4c72ee.zip
test: add a test that witnesses #1318
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 98ea92ca..62e9a457 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -4466,6 +4466,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"(