diff options
author | chriseth <c@ethdev.com> | 2015-06-01 21:09:05 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-06-01 21:09:05 +0800 |
commit | 80904d59e971f63740f3366f1302ad2371b45ad3 (patch) | |
tree | 3dfb1b2eb5fb245a9594814360054bf78a34ad34 | |
parent | 24cb1da067424bf872318bd392f25f7a20d9f106 (diff) | |
parent | 786b57b88483c2f44c2b7ed4117ea43febd7f42b (diff) | |
download | dexon-solidity-80904d59e971f63740f3366f1302ad2371b45ad3.tar.gz dexon-solidity-80904d59e971f63740f3366f1302ad2371b45ad3.tar.zst dexon-solidity-80904d59e971f63740f3366f1302ad2371b45ad3.zip |
Merge pull request #2029 from chriseth/sol_strings
Re-introduce string type.
-rw-r--r-- | libsolidity/SolidityABIJSON.cpp | 27 | ||||
-rw-r--r-- | libsolidity/SolidityNameAndTypeResolution.cpp | 33 |
2 files changed, 60 insertions, 0 deletions
diff --git a/libsolidity/SolidityABIJSON.cpp b/libsolidity/SolidityABIJSON.cpp index f9bf78d0..f7390dc9 100644 --- a/libsolidity/SolidityABIJSON.cpp +++ b/libsolidity/SolidityABIJSON.cpp @@ -568,6 +568,33 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(strings_and_arrays) +{ + // bug #1801 + char const* sourceCode = R"( + contract test { + function f(string a, bytes b, uint[] c) external {} + } + )"; + + char const* interface = R"( + [ + { + "constant" : false, + "name": "f", + "inputs": [ + { "name": "a", "type": "string" }, + { "name": "b", "type": "bytes" }, + { "name": "c", "type": "uint256[]" } + ], + "outputs": [], + "type" : "function" + } + ] + )"; + checkInterface(sourceCode, interface); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index c52bbf9d..48404aaa 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1783,6 +1783,39 @@ BOOST_AUTO_TEST_CASE(uninitialized_var) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(string) +{ + char const* sourceCode = R"( + contract C { + string s; + function f(string x) external { s = x; } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); +} + +BOOST_AUTO_TEST_CASE(string_index) +{ + char const* sourceCode = R"( + contract C { + string s; + function f() { var a = s[2]; } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + +BOOST_AUTO_TEST_CASE(string_length) +{ + char const* sourceCode = R"( + contract C { + string s; + function f() { var a = s.length; } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } |