diff options
author | chriseth <chris@ethereum.org> | 2016-10-21 17:27:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-21 17:27:36 +0800 |
commit | 984b8ac1b58309757380101aad644d3b1b30a2cd (patch) | |
tree | 422ff1843ea8f002e8a3d42a2c12f7265b13b971 /test | |
parent | 5875890576eb95dd73bc04b5e864975cd7a55f43 (diff) | |
parent | 13b2101ea7b55bc310682935bea4f4e5b07947c6 (diff) | |
download | dexon-solidity-984b8ac1b58309757380101aad644d3b1b30a2cd.tar.gz dexon-solidity-984b8ac1b58309757380101aad644d3b1b30a2cd.tar.zst dexon-solidity-984b8ac1b58309757380101aad644d3b1b30a2cd.zip |
Merge pull request #1261 from ethereum/inline-assembly-in-modifiers
Fix inline assembly variable access within modifiers
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 22 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 51 |
2 files changed, 73 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 088fe4d1..0a028a45 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7304,6 +7304,28 @@ BOOST_AUTO_TEST_CASE(shift_negative_constant_right) BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(-0x42))); } +BOOST_AUTO_TEST_CASE(inline_assembly_in_modifiers) +{ + char const* sourceCode = R"( + contract C { + modifier m { + uint a = 1; + assembly { + a := 2 + } + if (a != 2) + throw; + _; + } + function f() m returns (bool) { + return true; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(true)); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 83472369..2c69f663 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -4107,6 +4107,57 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack) BOOST_CHECK(expectError(text, true) == Error::Type::Warning); } +BOOST_AUTO_TEST_CASE(inline_assembly_in_modifier) +{ + char const* text = R"( + contract test { + modifier m { + uint a = 1; + assembly { + a := 2 + } + _; + } + function f() m { + } + } + )"; + BOOST_CHECK(success(text)); +} + +BOOST_AUTO_TEST_CASE(inline_assembly_storage) +{ + char const* text = R"( + contract test { + uint x = 1; + function f() { + assembly { + x := 2 + } + } + } + )"; + BOOST_CHECK(expectError(text, false) == Error::Type::DeclarationError); +} + +BOOST_AUTO_TEST_CASE(inline_assembly_storage_in_modifiers) +{ + char const* text = R"( + contract test { + uint x = 1; + modifier m { + assembly { + x := 2 + } + _; + } + function f() m { + } + } + )"; + BOOST_CHECK(expectError(text, false) == Error::Type::DeclarationError); +} + BOOST_AUTO_TEST_SUITE_END() } |