diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-09-07 07:16:49 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2016-10-20 07:03:09 +0800 |
commit | 59603f7b8e0fe2847979fe066fb15ecdc911f3e3 (patch) | |
tree | 6b9c0422b88ebdaa5cc162d7845d1375ceae146b /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | 33250eef9e3322a366a71fbd55df12e829d70726 (diff) | |
download | dexon-solidity-59603f7b8e0fe2847979fe066fb15ecdc911f3e3.tar.gz dexon-solidity-59603f7b8e0fe2847979fe066fb15ecdc911f3e3.tar.zst dexon-solidity-59603f7b8e0fe2847979fe066fb15ecdc911f3e3.zip |
Add tests for constant shifts
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 692abe57..088fe4d1 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7260,6 +7260,50 @@ BOOST_AUTO_TEST_CASE(mem_resize_is_not_paid_at_call) BOOST_CHECK(callContractFunction("f(address)", cAddrOpt) == encodeArgs(u256(7))); } +BOOST_AUTO_TEST_CASE(shift_constant_left) +{ + char const* sourceCode = R"( + contract C { + uint public a = 0x42 << 8; + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(0x4200))); +} + +BOOST_AUTO_TEST_CASE(shift_negative_constant_left) +{ + char const* sourceCode = R"( + contract C { + int public a = -0x42 << 8; + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(-0x4200))); +} + +BOOST_AUTO_TEST_CASE(shift_constant_right) +{ + char const* sourceCode = R"( + contract C { + uint public a = 0x4200 >> 8; + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(0x42))); +} + +BOOST_AUTO_TEST_CASE(shift_negative_constant_right) +{ + char const* sourceCode = R"( + contract C { + int public a = -0x4200 >> 8; + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(-0x42))); +} + BOOST_AUTO_TEST_SUITE_END() } |