diff options
author | chriseth <chris@ethereum.org> | 2018-02-13 19:03:02 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-02-13 21:15:02 +0800 |
commit | aea9e7fe549d93436a1eb355258ea1b11b5dfb22 (patch) | |
tree | 0dd9e19a1ae44e1245baa03f9ecf9b9a3dfbd206 | |
parent | 5916cf1e0ace5d9855af4d785c22c742cf106b8a (diff) | |
download | dexon-solidity-aea9e7fe549d93436a1eb355258ea1b11b5dfb22.tar.gz dexon-solidity-aea9e7fe549d93436a1eb355258ea1b11b5dfb22.tar.zst dexon-solidity-aea9e7fe549d93436a1eb355258ea1b11b5dfb22.zip |
Add tests for selectors for public variables.
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 11 | ||||
-rw-r--r-- | test/libsolidity/ViewPureChecker.cpp | 3 |
2 files changed, 10 insertions, 4 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 5b98d979..0611e71d 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -10219,24 +10219,29 @@ BOOST_AUTO_TEST_CASE(function_types_sig) { char const* sourceCode = R"( contract C { - function f() returns (bytes4) { + uint public x; + function f() pure returns (bytes4) { return this.f.selector; } function g() returns (bytes4) { - function () external returns (bytes4) fun = this.f; + function () pure external returns (bytes4) fun = this.f; return fun.selector; } function h() returns (bytes4) { - function () external returns (bytes4) fun = this.f; + function () pure external returns (bytes4) fun = this.f; var funvar = fun; return funvar.selector; } + function i() pure returns (bytes4) { + return this.x.selector; + } } )"; compileAndRun(sourceCode, 0, "C"); ABI_CHECK(callContractFunction("f()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes()))); ABI_CHECK(callContractFunction("g()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes()))); ABI_CHECK(callContractFunction("h()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes()))); + ABI_CHECK(callContractFunction("i()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("x()")).asBytes()))); } BOOST_AUTO_TEST_CASE(constant_string) diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp index 0fee95c5..3a03c877 100644 --- a/test/libsolidity/ViewPureChecker.cpp +++ b/test/libsolidity/ViewPureChecker.cpp @@ -330,10 +330,11 @@ BOOST_AUTO_TEST_CASE(selector) { string text = R"( contract C { + uint public x; function f() payable public { } function g() pure public returns (bytes4) { - return this.f.selector; + return this.f.selector ^ this.x.selector; } } )"; |