Skip to content

Commit

Permalink
Add tests for revert()
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Feb 9, 2017
1 parent f42326a commit 5707db7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/libsolidity/InlineAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ BOOST_AUTO_TEST_CASE(inline_assembly_shadowed_instruction_functional_assignment)
BOOST_CHECK(!successAssemble("{ gas := 2 }"));
}

BOOST_AUTO_TEST_CASE(revert)
{
BOOST_CHECK(successAssemble("{ revert(0, 0) }"));
}

BOOST_AUTO_TEST_SUITE_END()

}
Expand Down
19 changes: 19 additions & 0 deletions test/libsolidity/SolidityEndToEndTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9077,6 +9077,25 @@ BOOST_AUTO_TEST_CASE(invalid_instruction)
BOOST_CHECK(callContractFunction("f()") == encodeArgs());
}

BOOST_AUTO_TEST_CASE(revert)
{
char const* sourceCode = R"(
contract C {
function f() {
revert();
}
function g() {
assembly {
revert(0, 0)
}
}
}
)";
compileAndRun(sourceCode, 0, "C");
BOOST_CHECK(callContractFunction("f()") == encodeArgs());
BOOST_CHECK(callContractFunction("g()") == encodeArgs());
}

BOOST_AUTO_TEST_SUITE_END()

}
Expand Down

0 comments on commit 5707db7

Please sign in to comment.