diff options
author | RJ <catalanor0220@gmail.com> | 2016-01-10 15:07:02 +0800 |
---|---|---|
committer | RJ <catalanor0220@gmail.com> | 2016-01-10 15:07:02 +0800 |
commit | 10a1c352b9c274ba24b9915dfe2d6088616a69c2 (patch) | |
tree | 369c37265d983f27a51770691ff78a3d3c4b2218 /test | |
parent | b158e48c1a8be7258f283be049c1db779e661998 (diff) | |
download | dexon-solidity-10a1c352b9c274ba24b9915dfe2d6088616a69c2.tar.gz dexon-solidity-10a1c352b9c274ba24b9915dfe2d6088616a69c2.tar.zst dexon-solidity-10a1c352b9c274ba24b9915dfe2d6088616a69c2.zip |
Update with type resolution tests for arrays
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 84 |
1 files changed, 76 insertions, 8 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 70c9eb0d..3a865f8c 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2769,15 +2769,83 @@ BOOST_AUTO_TEST_CASE(function_overload_array_type) BOOST_CHECK(success(text)); } -/*BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing) +BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion) +{ + char const* text = R"( + contract C { + function f() returns (uint) { + uint8 x = 7; + uint16 y = 8; + uint32 z = 9; + uint32[3] memory ending = [x, y, z]; + return (ending[1]); + } + } + )"; + BOOST_CHECK(success(text)); + +} + +BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion_strings) { char const* text = R"( contract C { - uint[] a; - function f() returns (uint, uint) { - a = [1,2,3]; - return (a[3], [3,4][0]); - } + function f() returns (string) { + string memory x = "Hello"; + string memory y = "World"; + string[2] memory z = [x, y]; + return (z[0]); + } + } + )"; + BOOST_CHECK(success(text)); +} + +BOOST_AUTO_TEST_CASE(inline_array_declaration_const_int_conversion) +{ + char const* text = R"( + contract C { + function f() returns (uint) { + uint8[4] memory z = [1,2,3,5]; + return (z[0]); + } + } + )"; + BOOST_CHECK(success(text)); +} + +BOOST_AUTO_TEST_CASE(inline_array_declaration_const_string_conversion) +{ + char const* text = R"( + contract C { + function f() returns (string) { + string[2] memory z = ["Hello", "World"]; + return (z[0]); + } + } + )"; + BOOST_CHECK(success(text)); +} + +BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type) +{ + char const* text = R"( + contract C { + function f() returns (uint) { + return ([4,5,6][1]); + } + } + )"; + BOOST_CHECK(success(text)); +} + +BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type_strings) +{ + char const* text = R"( + contract C { + function f() returns (string) { + return (["foo", "man", "choo"][1]); + } } )"; BOOST_CHECK(success(text)); @@ -2788,12 +2856,12 @@ BOOST_AUTO_TEST_CASE(invalid_types_in_inline_array) char const* text = R"( contract C { function f() { - uint[] x = [45, "foo", true]; + uint[3] x = [45, 'foo', true]; } } )"; BOOST_CHECK(expectError(text) == Error::Type::TypeError); -}*/ +} BOOST_AUTO_TEST_SUITE_END() |