diff options
author | Gav Wood <g@ethdev.com> | 2015-02-05 02:19:16 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-02-05 02:19:16 +0800 |
commit | 4833b45fb39c8acbd54a0c20f5fe01f908fcc266 (patch) | |
tree | a01a43a2dfca36187b0256908ab4d1d28ce615a3 | |
parent | 458e65f3cb74dc112e11616e4860bafa7ad07149 (diff) | |
parent | 7eece799f2aefa521d0cee7e7773e8c4235a0b1c (diff) | |
download | dexon-solidity-4833b45fb39c8acbd54a0c20f5fe01f908fcc266.tar dexon-solidity-4833b45fb39c8acbd54a0c20f5fe01f908fcc266.tar.gz dexon-solidity-4833b45fb39c8acbd54a0c20f5fe01f908fcc266.tar.bz2 dexon-solidity-4833b45fb39c8acbd54a0c20f5fe01f908fcc266.tar.lz dexon-solidity-4833b45fb39c8acbd54a0c20f5fe01f908fcc266.tar.xz dexon-solidity-4833b45fb39c8acbd54a0c20f5fe01f908fcc266.tar.zst dexon-solidity-4833b45fb39c8acbd54a0c20f5fe01f908fcc266.zip |
Merge pull request #949 from guanqun/add-some-tests-for-named-args
fix bug of duplicate name args due to refactoring of m_names
-rw-r--r-- | SolidityNameAndTypeResolution.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index 1a087592..ae6c374b 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -868,6 +868,42 @@ BOOST_AUTO_TEST_CASE(access_to_protected_state_variable) BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); } +BOOST_AUTO_TEST_CASE(error_count_in_named_args) +{ + char const* sourceCode = "contract test {\n" + " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" + " function b() returns (uint r) { r = a({a: 1}); }\n" + "}\n"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + +BOOST_AUTO_TEST_CASE(empty_in_named_args) +{ + char const* sourceCode = "contract test {\n" + " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" + " function b() returns (uint r) { r = a({}); }\n" + "}\n"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + +BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args) +{ + char const* sourceCode = "contract test {\n" + " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" + " function b() returns (uint r) { r = a({a: 1, a: 2}); }\n" + "}\n"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + +BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args) +{ + char const* sourceCode = "contract test {\n" + " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" + " function b() returns (uint r) { r = a({a: 1, c: 2}); }\n" + "}\n"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } |