aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-10-06 19:50:15 +0800
committerGitHub <noreply@github.com>2017-10-06 19:50:15 +0800
commit094012dbb046655ac0291f6c4632f306406c0ada (patch)
tree56f31dfd7a35727b7781db63253e7037395d8337 /test
parent961f8746ffb169b564ac625a3cb0b215ec671757 (diff)
parent475b81880185e816db9a962a06cb3c323b953a90 (diff)
downloaddexon-solidity-094012dbb046655ac0291f6c4632f306406c0ada.tar
dexon-solidity-094012dbb046655ac0291f6c4632f306406c0ada.tar.gz
dexon-solidity-094012dbb046655ac0291f6c4632f306406c0ada.tar.bz2
dexon-solidity-094012dbb046655ac0291f6c4632f306406c0ada.tar.lz
dexon-solidity-094012dbb046655ac0291f6c4632f306406c0ada.tar.xz
dexon-solidity-094012dbb046655ac0291f6c4632f306406c0ada.tar.zst
dexon-solidity-094012dbb046655ac0291f6c4632f306406c0ada.zip
Merge pull request #3036 from ethereum/constant-eval-refactor
Refactor error reporting in 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 c3dacc3d..903e7308 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -7122,7 +7122,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 {
@@ -7132,6 +7132,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"(