|
|
@ -28,10 +28,6 @@ |
|
|
|
#include <libdevcrypto/SHA3.h> |
|
|
|
#include <test/solidityExecutionFramework.h> |
|
|
|
|
|
|
|
#ifdef _MSC_VER |
|
|
|
#pragma warning(disable: 4307) //integral constant overflow for high_bits_cleaning
|
|
|
|
#endif |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
namespace dev |
|
|
@ -386,7 +382,8 @@ 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" |
|
|
|
" uint32 t = uint32(0xffffffff);\n" |
|
|
|
" uint32 x = t + 10;\n" |
|
|
|
" if (x >= 0xffffffff) return 0;\n" |
|
|
|
" return x;" |
|
|
|
" }\n" |
|
|
@ -394,7 +391,8 @@ BOOST_AUTO_TEST_CASE(high_bits_cleaning) |
|
|
|
compileAndRun(sourceCode); |
|
|
|
auto high_bits_cleaning_cpp = []() -> u256 |
|
|
|
{ |
|
|
|
uint32_t x = uint32_t(0xffffffff) + 10; |
|
|
|
uint32_t t = uint32_t(0xffffffff); |
|
|
|
uint32_t x = t + 10; |
|
|
|
if (x >= 0xffffffff) |
|
|
|
return 0; |
|
|
|
return x; |
|
|
@ -426,14 +424,16 @@ BOOST_AUTO_TEST_CASE(small_unsigned_types) |
|
|
|
{ |
|
|
|
char const* sourceCode = "contract test {\n" |
|
|
|
" function run() returns(uint256 y) {\n" |
|
|
|
" uint32 x = uint32(0xffffff) * 0xffffff;\n" |
|
|
|
" uint32 t = uint32(0xffffff);\n" |
|
|
|
" uint32 x = t * 0xffffff;\n" |
|
|
|
" return x / 0x100;" |
|
|
|
" }\n" |
|
|
|
"}\n"; |
|
|
|
compileAndRun(sourceCode); |
|
|
|
auto small_unsigned_types_cpp = []() -> u256 |
|
|
|
{ |
|
|
|
uint32_t x = uint32_t(0xffffff) * 0xffffff; |
|
|
|
uint32_t t = uint32_t(0xffffff); |
|
|
|
uint32_t x = t * 0xffffff; |
|
|
|
return x / 0x100; |
|
|
|
}; |
|
|
|
testSolidityAgainstCpp("run()", small_unsigned_types_cpp); |
|
|
|