From 010710353a4097f5dc94e42130ce22e6f0c72beb Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 4 Nov 2014 19:13:03 +0100 Subject: Proper type promotion and conversion. --- solidityEndToEndTest.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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() -- cgit