diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-04-12 00:01:01 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-04-12 00:01:24 +0800 |
commit | fdcbf1337a018087fe82a2fbef938d0acd6769f9 (patch) | |
tree | 4a598510c2f7514717ad16c066fe1cd5d62c097d /test/libsolidity/SolidityNameAndTypeResolution.cpp | |
parent | d50d1f0ac1841a1d287a216451e93573fc07474e (diff) | |
download | dexon-solidity-fdcbf1337a018087fe82a2fbef938d0acd6769f9.tar dexon-solidity-fdcbf1337a018087fe82a2fbef938d0acd6769f9.tar.gz dexon-solidity-fdcbf1337a018087fe82a2fbef938d0acd6769f9.tar.bz2 dexon-solidity-fdcbf1337a018087fe82a2fbef938d0acd6769f9.tar.lz dexon-solidity-fdcbf1337a018087fe82a2fbef938d0acd6769f9.tar.xz dexon-solidity-fdcbf1337a018087fe82a2fbef938d0acd6769f9.tar.zst dexon-solidity-fdcbf1337a018087fe82a2fbef938d0acd6769f9.zip |
Syntax Tests: extract array_length_* tests.
Diffstat (limited to 'test/libsolidity/SolidityNameAndTypeResolution.cpp')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 165 |
1 files changed, 0 insertions, 165 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index fcee0df3..293f5f44 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -7720,171 +7720,6 @@ BOOST_AUTO_TEST_CASE(address_overload_resolution) CHECK_SUCCESS(text); } -BOOST_AUTO_TEST_CASE(array_length_too_large) -{ - char const* text = R"( - contract C { - uint[8**90] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -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 or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_constant_var) -{ - char const* text = R"( - contract C { - uint constant LEN = 10; - uint[LEN] ids; - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_non_integer_constant_var) -{ - char const* text = R"( - contract C { - bool constant LEN = true; - uint[LEN] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_cannot_be_function) -{ - char const* text = R"( - contract C { - function f() {} - uint[f] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_can_be_recursive_constant) -{ - char const* text = R"( - contract C { - uint constant L = 5; - uint constant LEN = L + 4 * L; - uint[LEN] ids; - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_cannot_be_function_call) -{ - char const* text = R"( - contract C { - function f(uint x) {} - uint constant LEN = f(); - uint[LEN] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_const_cannot_be_fractional) -{ - char const* text = R"( - contract C { - fixed constant L = 10.5; - uint[L] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Array with fractional length specified"); -} - -BOOST_AUTO_TEST_CASE(array_length_can_be_constant_in_struct) -{ - char const* text = R"( - contract C { - uint constant LEN = 10; - struct Test { - uint[LEN] ids; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_can_be_constant_in_function) -{ - char const* text = R"( - contract C { - uint constant LEN = 10; - function f() { - uint[LEN] a; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_cannot_be_constant_function_parameter) -{ - char const* text = R"( - contract C { - function f(uint constant LEN) { - uint[LEN] a; - } - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_with_cyclic_constant) -{ - char const* text = R"( - contract C { - uint constant LEN = LEN; - function f() { - uint[LEN] a; - } - } - )"; - CHECK_ERROR(text, TypeError, "Cyclic constant definition (or maximum recursion depth exhausted)."); -} - -BOOST_AUTO_TEST_CASE(array_length_with_complex_cyclic_constant) -{ - char const* text = R"( - contract C { - uint constant L2 = LEN - 10; - uint constant L1 = L2 / 10; - uint constant LEN = 10 + L1 * 5; - function f() { - uint[LEN] a; - } - } - )"; - CHECK_ERROR(text, TypeError, "Cyclic constant definition (or maximum recursion depth exhausted)."); -} - -BOOST_AUTO_TEST_CASE(array_length_with_pure_functions) -{ - char const* text = R"( - contract C { - uint constant LEN = keccak256(ripemd160(33)); - uint[LEN] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - BOOST_AUTO_TEST_CASE(array_length_invalid_expression) { char const* text = R"( |