diff options
author | bitshift <bitshift@posteo.org> | 2018-03-10 00:46:24 +0800 |
---|---|---|
committer | Erik Kundt <bitshift@posteo.org> | 2018-05-29 18:53:02 +0800 |
commit | e9dcfb0b624e5443942451fc865c154a2c5a73d7 (patch) | |
tree | 0c898c43537109fb786a979a981150e79806229a /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | 8f04c59046595216e9fffd93435055aa864fbd1f (diff) | |
download | dexon-solidity-e9dcfb0b624e5443942451fc865c154a2c5a73d7.tar.gz dexon-solidity-e9dcfb0b624e5443942451fc865c154a2c5a73d7.tar.zst dexon-solidity-e9dcfb0b624e5443942451fc865c154a2c5a73d7.zip |
Implements pop() for value type arrays.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 40962294..b4cf6950 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5111,6 +5111,72 @@ BOOST_AUTO_TEST_CASE(byte_array_push_transition) ABI_CHECK(callContractFunction("test()"), encodeArgs(0)); } +BOOST_AUTO_TEST_CASE(array_pop) +{ + char const* sourceCode = R"( + contract c { + uint[] data; + function test() public returns (uint x, uint y, uint l) { + data.push(7); + x = data.push(3); + data.pop(); + y = data.push(2); + l = data.length; + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("test()"), encodeArgs(2, 2, 2)); +} + +BOOST_AUTO_TEST_CASE(array_pop_empty) +{ + char const* sourceCode = R"( + contract c { + uint[] data; + function test() public returns (bool) { + data.pop(); + return true; + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("test()"), encodeArgs()); +} + +BOOST_AUTO_TEST_CASE(bytearray_pop) +{ + char const* sourceCode = R"( + contract c { + bytes data; + function test() public returns (uint x, uint y, uint l) { + data.push(7); + x = data.push(3); + data.pop(); + data.pop(); + y = data.push(2); + l = data.length; + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("test()"), encodeArgs(2, 1, 1)); +} + +BOOST_AUTO_TEST_CASE(bytearray_pop_empty) +{ + char const* sourceCode = R"( + contract c { + bytes data; + function test() public returns (bool) { + data.pop(); + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("test()"), encodeArgs()); +} + BOOST_AUTO_TEST_CASE(external_array_args) { char const* sourceCode = R"( |