aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-11-17 08:47:47 +0800
committerchriseth <c@ethdev.com>2015-11-26 20:10:12 +0800
commitbf55aa6ae2b9aeec09bb8cf1e3715afd7dd59b7e (patch)
treee49bc5845496df706ea45de03748c5475611c3b9 /test/libsolidity
parent30b325fdc148d5014f04fd238362e3a1df10310f (diff)
downloaddexon-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.cpp38
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()
}