diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-03-06 01:01:42 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-03-06 01:45:02 +0800 |
commit | 2213f9946b34a6e8f5604a6b821d31788dcee08b (patch) | |
tree | d4274ee682e3dccdf4bee18d3ac0a6e5842d02e2 | |
parent | 3340053fd95b73facc8a1534a130f58698808f2e (diff) | |
download | dexon-solidity-2213f9946b34a6e8f5604a6b821d31788dcee08b.tar.gz dexon-solidity-2213f9946b34a6e8f5604a6b821d31788dcee08b.tar.zst dexon-solidity-2213f9946b34a6e8f5604a6b821d31788dcee08b.zip |
Improved gasleft tests.
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 12 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 14 |
2 files changed, 19 insertions, 7 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c352a2c2..ebb2f3ff 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5352,6 +5352,18 @@ BOOST_AUTO_TEST_CASE(super_overload) ABI_CHECK(callContractFunction("h()"), encodeArgs(2)); } +BOOST_AUTO_TEST_CASE(gasleft_shadow_resolution) +{ + char const* sourceCode = R"( + contract C { + function gasleft() returns(uint256) { return 0; } + function f() returns(uint256) { return gasleft(); } + } + )"; + compileAndRun(sourceCode, 0, "C"); + ABI_CHECK(callContractFunction("f()"), encodeArgs(0)); +} + BOOST_AUTO_TEST_CASE(bool_conversion) { char const* sourceCode = R"( diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 43c9bc9b..f08f695b 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -7409,21 +7409,21 @@ BOOST_AUTO_TEST_CASE(builtin_reject_gas) CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup"); } -BOOST_AUTO_TEST_CASE(gas_left) +BOOST_AUTO_TEST_CASE(gasleft) { char const* text = R"( contract C { - function f() public returns (uint256 val) { return msg.gas; } + function f() public view returns (uint256 val) { return msg.gas; } } )"; - CHECK_SUCCESS(text); + CHECK_SUCCESS_NO_WARNINGS(text); text = R"( contract C { - function f() public returns (uint256 val) { return gasleft(); } + function f() public view returns (uint256 val) { return gasleft(); } } )"; - CHECK_SUCCESS(text); + CHECK_SUCCESS_NO_WARNINGS(text); text = R"( pragma experimental "v0.5.0"; @@ -7434,12 +7434,12 @@ BOOST_AUTO_TEST_CASE(gas_left) CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup in msg"); } -BOOST_AUTO_TEST_CASE(gasleft_as_identifier) +BOOST_AUTO_TEST_CASE(gasleft_shadowing) { char const* text = R"( contract C { function gasleft() public pure returns (bytes32 val) { return "abc"; } - function f() public pure { bytes32 val = gasleft(); assert (val == "abc"); } + function f() public pure returns (bytes32 val) { return gasleft(); } } )"; CHECK_WARNING(text, "This declaration shadows a builtin symbol."); |