aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-03-03 00:58:27 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-03-05 18:18:04 +0800
commitc633c0eacba12e940b12c6ff58b5c6c55dc0122c (patch)
tree9b54278c28df1c2fb97916c9ec7e263faea1b97d /test/libsolidity/SolidityEndToEndTest.cpp
parent5982869e94965e48ec680fd32e6f80b8211fc34c (diff)
downloaddexon-solidity-c633c0eacba12e940b12c6ff58b5c6c55dc0122c.tar.gz
dexon-solidity-c633c0eacba12e940b12c6ff58b5c6c55dc0122c.tar.zst
dexon-solidity-c633c0eacba12e940b12c6ff58b5c6c55dc0122c.zip
Move msg.gas to global function gasleft(). Closes #2971.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp19
1 files changed, 19 insertions, 0 deletions
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"(