diff options
author | chriseth <chris@ethereum.org> | 2017-06-22 18:22:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-22 18:22:28 +0800 |
commit | 1c54ce2a2caa6c4d91091152ad8a52b7881e8b83 (patch) | |
tree | 3d4e9cc3a050f214bcd7649d0124c7c5f31582d5 /test/liblll/EndToEndTest.cpp | |
parent | 3094e777486c40c91c6cf3432ad60f29b9ada484 (diff) | |
parent | bc95da354d78912f1b2d1a726f072fb855f2c219 (diff) | |
download | dexon-solidity-1c54ce2a2caa6c4d91091152ad8a52b7881e8b83.tar.gz dexon-solidity-1c54ce2a2caa6c4d91091152ad8a52b7881e8b83.tar.zst dexon-solidity-1c54ce2a2caa6c4d91091152ad8a52b7881e8b83.zip |
Merge pull request #2399 from ethereum/lll-if
LLL: Replace obsolete assembly code
Diffstat (limited to 'test/liblll/EndToEndTest.cpp')
-rw-r--r-- | test/liblll/EndToEndTest.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp index 3668038d..a01eaca0 100644 --- a/test/liblll/EndToEndTest.cpp +++ b/test/liblll/EndToEndTest.cpp @@ -57,6 +57,68 @@ BOOST_AUTO_TEST_CASE(panic) BOOST_REQUIRE(m_output.empty()); } +BOOST_AUTO_TEST_CASE(when) +{ + char const* sourceCode = R"( + (returnlll + (seq + (when (= (calldatasize) 0) (return 1)) + (when (!= (calldatasize) 0) (return 2)))) + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(2))); + BOOST_CHECK(callFallback() == toBigEndian(u256(1))); +} + +BOOST_AUTO_TEST_CASE(unless) +{ + char const* sourceCode = R"( + (returnlll + (seq + (unless (!= (calldatasize) 0) (return 1)) + (unless (= (calldatasize) 0) (return 2)))) + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(2))); + BOOST_CHECK(callFallback() == toBigEndian(u256(1))); +} + +BOOST_AUTO_TEST_CASE(conditional_literal) +{ + char const* sourceCode = R"( + (returnlll + (seq + (return (if (= (calldatasize) 0) 1 2)))) + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(2))); + BOOST_CHECK(callFallback() == toBigEndian(u256(1))); +} + +BOOST_AUTO_TEST_CASE(conditional) +{ + char const* sourceCode = R"( + (returnlll + (seq + (if (= (calldatasize) 0) (return 1) (return 2)))) + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(2))); + BOOST_CHECK(callFallback() == toBigEndian(u256(1))); +} + +BOOST_AUTO_TEST_CASE(conditional_seq) +{ + char const* sourceCode = R"( + (returnlll + (seq + (return (if (= (calldatasize) 0) { 0 2 1 } { 0 1 2 })))) + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(2))); + BOOST_CHECK(callFallback() == toBigEndian(u256(1))); +} + BOOST_AUTO_TEST_CASE(exp_operator_const) { char const* sourceCode = R"( |