From c633c0eacba12e940b12c6ff58b5c6c55dc0122c Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 2 Mar 2018 17:58:27 +0100 Subject: Move msg.gas to global function gasleft(). Closes #2971. --- test/libsolidity/SolidityEndToEndTest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/libsolidity/SolidityEndToEndTest.cpp') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c352a2c2..e61afb0e 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -2481,6 +2481,25 @@ BOOST_AUTO_TEST_CASE(gas_and_value_basic) BOOST_REQUIRE(callContractFunction("checkState()") == encodeArgs(false, 20 - 5)); } +BOOST_AUTO_TEST_CASE(gas_left) +{ + char const* sourceCode = R"( + contract test { + function getGasLeft() public returns (uint256 val) { return msg.gas; } + } + )"; + compileAndRun(sourceCode); + BOOST_REQUIRE(callContractFunction("getGasLeft()") == encodeArgs(99978604)); + + sourceCode = R"( + contract test { + function getGasLeft() public returns (uint256 val) { return gasleft(); } + } + )"; + compileAndRun(sourceCode); + BOOST_REQUIRE(callContractFunction("getGasLeft()") == encodeArgs(99978604)); +} + BOOST_AUTO_TEST_CASE(value_complex) { char const* sourceCode = R"( -- cgit v1.2.3