aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-10-06 03:08:12 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-10-06 03:08:12 +0800
commitc28ed2a6191fd16c4be92a9adb53d5ff3215a34d (patch)
treeb39605b5350b2f69b23c51b741660e5c80d96530 /test
parentb8e904616a22507371fd994a3193412711ab6ddd (diff)
downloaddexon-solidity-c28ed2a6191fd16c4be92a9adb53d5ff3215a34d.tar
dexon-solidity-c28ed2a6191fd16c4be92a9adb53d5ff3215a34d.tar.gz
dexon-solidity-c28ed2a6191fd16c4be92a9adb53d5ff3215a34d.tar.bz2
dexon-solidity-c28ed2a6191fd16c4be92a9adb53d5ff3215a34d.tar.lz
dexon-solidity-c28ed2a6191fd16c4be92a9adb53d5ff3215a34d.tar.xz
dexon-solidity-c28ed2a6191fd16c4be92a9adb53d5ff3215a34d.tar.zst
dexon-solidity-c28ed2a6191fd16c4be92a9adb53d5ff3215a34d.zip
Add tests for ConstantEvaluator
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a6fc4e34..9972d795 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -7102,7 +7102,7 @@ BOOST_AUTO_TEST_CASE(address_overload_resolution)
CHECK_SUCCESS(text);
}
-BOOST_AUTO_TEST_CASE(array_length_validation)
+BOOST_AUTO_TEST_CASE(array_length_too_large)
{
char const* text = R"(
contract C {
@@ -7112,6 +7112,44 @@ BOOST_AUTO_TEST_CASE(array_length_validation)
CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal.");
}
+BOOST_AUTO_TEST_CASE(array_length_not_convertible_to_integer)
+{
+ char const* text = R"(
+ contract C {
+ uint[true] ids;
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal.");
+}
+
+BOOST_AUTO_TEST_CASE(array_length_invalid_expression)
+{
+ char const* text = R"(
+ contract C {
+ uint[-true] ids;
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Invalid constant expression.");
+ text = R"(
+ contract C {
+ uint[true/1] ids;
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Invalid constant expression.");
+ text = R"(
+ contract C {
+ uint[1/true] ids;
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Invalid constant expression.");
+ text = R"(
+ contract C {
+ uint[1.111111E1111111111111] ids;
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Invalid literal value.");
+}
+
BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
{
char const* text = R"(