diff options
author | chriseth <c@ethdev.com> | 2015-11-17 08:47:47 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-11-26 20:10:12 +0800 |
commit | bf55aa6ae2b9aeec09bb8cf1e3715afd7dd59b7e (patch) | |
tree | e49bc5845496df706ea45de03748c5475611c3b9 /test/libsolidity | |
parent | 30b325fdc148d5014f04fd238362e3a1df10310f (diff) | |
download | dexon-solidity-bf55aa6ae2b9aeec09bb8cf1e3715afd7dd59b7e.tar.gz dexon-solidity-bf55aa6ae2b9aeec09bb8cf1e3715afd7dd59b7e.tar.zst dexon-solidity-bf55aa6ae2b9aeec09bb8cf1e3715afd7dd59b7e.zip |
Type checking for creating new arrays.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 3d9dc5b5..4f26fa4d 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2538,7 +2538,7 @@ BOOST_AUTO_TEST_CASE(create_memory_arrays) } contract C { function f(uint size) { - L.S[][] x = new L.S[][](10); + L.S[][] memory x = new L.S[][](10); var y = new uint[](20); var z = new bytes(size); } @@ -2547,6 +2547,42 @@ BOOST_AUTO_TEST_CASE(create_memory_arrays) BOOST_CHECK(success(text)); } +BOOST_AUTO_TEST_CASE(mapping_in_memory_array) +{ + char const* text = R"( + contract C { + function f(uint size) { + var x = new mapping(uint => uint)[](4); + } + } + )"; + BOOST_CHECK(expectError(text) == Error::Type::TypeError); +} + +BOOST_AUTO_TEST_CASE(new_for_non_array) +{ + char const* text = R"( + contract C { + function f(uint size) { + var x = new uint(7); + } + } + )"; + BOOST_CHECK(expectError(text) == Error::Type::TypeError); +} + +BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array) +{ + char const* text = R"( + contract C { + function f(uint size) { + var x = new uint[](); + } + } + )"; + BOOST_CHECK(expectError(text) == Error::Type::TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } |