diff options
author | chriseth <c@ethdev.com> | 2015-06-18 20:41:06 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-06-18 20:41:46 +0800 |
commit | 6d2f2f668ba2529aa2ed0bae88afc55b2869cd97 (patch) | |
tree | 72908c0f5421b3db96a99e207d2da14afecd02f8 /libsolidity/SolidityEndToEndTest.cpp | |
parent | 6c27ef73670185e5adf8f84c4bcfbf9ce860defd (diff) | |
download | dexon-solidity-6d2f2f668ba2529aa2ed0bae88afc55b2869cd97.tar.gz dexon-solidity-6d2f2f668ba2529aa2ed0bae88afc55b2869cd97.tar.zst dexon-solidity-6d2f2f668ba2529aa2ed0bae88afc55b2869cd97.zip |
Tests for constructor arguments "from outside".
Diffstat (limited to 'libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | libsolidity/SolidityEndToEndTest.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 66a8f882..7ee259ab 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -1726,7 +1726,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls) BOOST_CHECK(callContractFunction("callHelper(bytes2,bool)", string("\0a", 2), true) == encodeArgs(string("\0a\0\0\0", 5))); } -BOOST_AUTO_TEST_CASE(constructor_arguments) +BOOST_AUTO_TEST_CASE(constructor_arguments_internal) { char const* sourceCode = R"( contract Helper { @@ -1749,8 +1749,28 @@ BOOST_AUTO_TEST_CASE(constructor_arguments) function getName() returns (bytes3 ret) { return h.getName(); } })"; compileAndRun(sourceCode, 0, "Main"); - BOOST_REQUIRE(callContractFunction("getFlag()") == encodeArgs(true)); - BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc")); + BOOST_CHECK(callContractFunction("getFlag()") == encodeArgs(true)); + BOOST_CHECK(callContractFunction("getName()") == encodeArgs("abc")); +} + +BOOST_AUTO_TEST_CASE(constructor_arguments_external) +{ + char const* sourceCode = R"( + contract Main { + bytes3 name; + bool flag; + + function Main(bytes3 x, bool f) { + name = x; + flag = f; + } + function getName() returns (bytes3 ret) { return name; } + function getFlag() returns (bool ret) { return flag; } + } + )"; + compileAndRun(sourceCode, 0, "Main", encodeArgs("abc", true)); + BOOST_CHECK(callContractFunction("getFlag()") == encodeArgs(true)); + BOOST_CHECK(callContractFunction("getName()") == encodeArgs("abc")); } BOOST_AUTO_TEST_CASE(functions_called_by_constructor) @@ -4166,7 +4186,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) } } )"; - BOOST_CHECK(compileAndRunWthoutCheck(sourceCode, 0, "A").empty()); + BOOST_CHECK(compileAndRunWithoutCheck(sourceCode, 0, "A").empty()); } BOOST_AUTO_TEST_CASE(positive_integers_to_signed) |