aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-03-04 01:44:15 +0800
committerchriseth <c@ethdev.com>2017-03-06 21:27:18 +0800
commitc89a5798092cc7802680a62bf267b0eb8bcd8b6d (patch)
treee0215ef7a6ebd25d2d55be6cefbd32a554bcfe73 /test/libsolidity
parent5069c58a4be58d406585873a0d86852e17f9f89a (diff)
downloaddexon-solidity-c89a5798092cc7802680a62bf267b0eb8bcd8b6d.tar.gz
dexon-solidity-c89a5798092cc7802680a62bf267b0eb8bcd8b6d.tar.zst
dexon-solidity-c89a5798092cc7802680a62bf267b0eb8bcd8b6d.zip
Test for uninitialized mapping.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 3b137572..02d81d14 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2501,6 +2501,30 @@ BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable)
CHECK_ERROR(sourceCode, TypeError, "");
}
+BOOST_AUTO_TEST_CASE(uninitialized_mapping_variable)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() {
+ mapping(uint => uint) x;
+ }
+ }
+ )";
+ CHECK_ERROR(sourceCode, TypeError, "Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable");
+}
+
+BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() {
+ mapping(uint => uint)[] x;
+ }
+ }
+ )";
+ CHECK_WARNING(sourceCode, "Uninitialized storage pointer");
+}
+
BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers)
{
char const* sourceCode = R"(