diff options
author | chriseth <c@ethdev.com> | 2015-12-17 08:21:22 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-12-17 08:21:22 +0800 |
commit | eb11c7f43f2fdfe608716db8cf58775bc22ad440 (patch) | |
tree | f00e1a47c786cc4eaae63c8860a8652e22030779 /test | |
parent | 591a4f1ff44af20fce9bafebf0fa0607e2bdfcc0 (diff) | |
parent | ed1dd50acda058a9c0c5b9c43776fba3642e23e2 (diff) | |
download | dexon-solidity-eb11c7f43f2fdfe608716db8cf58775bc22ad440.tar dexon-solidity-eb11c7f43f2fdfe608716db8cf58775bc22ad440.tar.gz dexon-solidity-eb11c7f43f2fdfe608716db8cf58775bc22ad440.tar.bz2 dexon-solidity-eb11c7f43f2fdfe608716db8cf58775bc22ad440.tar.lz dexon-solidity-eb11c7f43f2fdfe608716db8cf58775bc22ad440.tar.xz dexon-solidity-eb11c7f43f2fdfe608716db8cf58775bc22ad440.tar.zst dexon-solidity-eb11c7f43f2fdfe608716db8cf58775bc22ad440.zip |
Merge pull request #305 from VoR0220/inlineArrays
Parsing for Inline Arrays is passing
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 26 | ||||
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 42 |
2 files changed, 68 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 73a9b660..1242e801 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2743,6 +2743,32 @@ BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array) BOOST_CHECK(expectError(text) == Error::Type::TypeError); } +/*BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing) +{ + char const* text = R"( + contract C { + uint[] a; + function f() returns (uint, uint) { + a = [1,2,3]; + return (a[3], [3,4][0]); + } + } + )"; + BOOST_CHECK(success(text)); +} + +BOOST_AUTO_TEST_CASE(invalid_types_in_inline_array) +{ + char const* text = R"( + contract C { + function f() { + uint[] x = [45, "foo", true]; + } + } + )"; + BOOST_CHECK(expectError(text) == Error::Type::TypeError); +}*/ + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index fd9076c3..e6c8a8d8 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -1047,6 +1047,48 @@ BOOST_AUTO_TEST_CASE(using_for) BOOST_CHECK(successParse(text)); } +BOOST_AUTO_TEST_CASE(inline_array_declaration) +{ + char const* text = R"( + contract c { + uint[] a; + function f() returns (uint, uint) { + a = [1,2,3]; + return (a[3], [2,3,4][0]); + } + } + )"; + BOOST_CHECK(successParse(text)); +} + + +BOOST_AUTO_TEST_CASE(inline_array_empty_cells_check_lvalue) +{ + char const* text = R"( + contract c { + uint[] a; + function f() returns (uint) { + a = [,2,3]; + return (a[0]); + } + } + )"; + BOOST_CHECK(!successParse(text)); +} + +BOOST_AUTO_TEST_CASE(inline_array_empty_cells_check_without_lvalue) +{ + char const* text = R"( + contract c { + uint[] a; + function f() returns (uint, uint) { + return ([3, ,4][0]); + } + } + )"; + BOOST_CHECK(!successParse(text)); +} + BOOST_AUTO_TEST_SUITE_END() } |