diff options
author | Christian <c@ethdev.com> | 2014-11-05 02:13:03 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-06 09:36:39 +0800 |
commit | 010710353a4097f5dc94e42130ce22e6f0c72beb (patch) | |
tree | 301dd30aaae8a22bd6e5d919a730e8ec1408f5dd | |
parent | e22cad4d35559cb76449a215ca519f9c0b812c7a (diff) | |
download | dexon-solidity-010710353a4097f5dc94e42130ce22e6f0c72beb.tar dexon-solidity-010710353a4097f5dc94e42130ce22e6f0c72beb.tar.gz dexon-solidity-010710353a4097f5dc94e42130ce22e6f0c72beb.tar.bz2 dexon-solidity-010710353a4097f5dc94e42130ce22e6f0c72beb.tar.lz dexon-solidity-010710353a4097f5dc94e42130ce22e6f0c72beb.tar.xz dexon-solidity-010710353a4097f5dc94e42130ce22e6f0c72beb.tar.zst dexon-solidity-010710353a4097f5dc94e42130ce22e6f0c72beb.zip |
Proper type promotion and conversion.
-rw-r--r-- | solidityEndToEndTest.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/solidityEndToEndTest.cpp b/solidityEndToEndTest.cpp index b28b8499..b4da53ba 100644 --- a/solidityEndToEndTest.cpp +++ b/solidityEndToEndTest.cpp @@ -219,7 +219,33 @@ BOOST_AUTO_TEST_CASE(short_circuiting) BOOST_CHECK(framework.callFunction(0, u256(1)) == toBigEndian(u256(8))); } -//@todo test smaller types +BOOST_AUTO_TEST_CASE(high_bits_cleaning) +{ + char const* sourceCode = "contract test {\n" + " function run() returns(uint256 y) {\n" + " uint32 x = uint32(0xffffffff) + 10;\n" + " if (x >= 0xffffffff) return 0;\n" + " return x;" + " }\n" + "}\n"; + ExecutionFramework framework; + framework.compileAndRun(sourceCode); + BOOST_CHECK(framework.callFunction(0, bytes()) == toBigEndian(u256(9))); +} + +BOOST_AUTO_TEST_CASE(sign_extension) +{ + char const* sourceCode = "contract test {\n" + " function run() returns(uint256 y) {\n" + " int64 x = -int32(0xff);\n" + " if (x >= 0xff) return 0;\n" + " return -uint256(x);" + " }\n" + "}\n"; + ExecutionFramework framework; + framework.compileAndRun(sourceCode); + BOOST_CHECK(framework.callFunction(0, bytes()) == bytes(32, 0xff)); +} BOOST_AUTO_TEST_SUITE_END() |