mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Improved gasleft tests.
This commit is contained in:
parent
3340053fd9
commit
2213f9946b
@ -5352,6 +5352,18 @@ BOOST_AUTO_TEST_CASE(super_overload)
|
|||||||
ABI_CHECK(callContractFunction("h()"), encodeArgs(2));
|
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)
|
BOOST_AUTO_TEST_CASE(bool_conversion)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
|
@ -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");
|
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"(
|
char const* text = R"(
|
||||||
contract C {
|
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"(
|
text = R"(
|
||||||
contract C {
|
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"(
|
text = R"(
|
||||||
pragma experimental "v0.5.0";
|
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");
|
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"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function gasleft() public pure returns (bytes32 val) { return "abc"; }
|
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.");
|
CHECK_WARNING(text, "This declaration shadows a builtin symbol.");
|
||||||
|
Loading…
Reference in New Issue
Block a user