Merge pull request #6888 from anurag-git/anurag_semantic_test_update

New semantic tests extracted
This commit is contained in:
Daniel Kirchner 2019-06-11 10:50:10 +02:00 committed by GitHub
commit bd1f65d609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 41 deletions

View File

@ -64,47 +64,6 @@ int constexpr roundTo32(int _num)
return (_num + 31) / 32 * 32;
}
BOOST_AUTO_TEST_CASE(transaction_status)
{
char const* sourceCode = R"(
contract test {
function f() public { }
function g() public { revert(); }
function h() public { assert(false); }
}
)";
compileAndRun(sourceCode);
callContractFunction("f()");
BOOST_CHECK(m_transactionSuccessful);
callContractFunction("g()");
BOOST_CHECK(!m_transactionSuccessful);
callContractFunction("h()");
BOOST_CHECK(!m_transactionSuccessful);
}
BOOST_AUTO_TEST_CASE(smoke_test)
{
char const* sourceCode = R"(
contract test {
function f(uint a) public returns(uint d) { return a * 7; }
}
)";
compileAndRun(sourceCode);
testContractAgainstCppOnRange("f(uint256)", [](u256 const& a) -> u256 { return a * 7; }, 0, 100);
}
BOOST_AUTO_TEST_CASE(empty_contract)
{
char const* sourceCode = R"(
contract test { }
)";
ALSO_VIA_YUL(
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()).empty());
)
}
BOOST_AUTO_TEST_CASE(exp_operator)
{
char const* sourceCode = R"(

View File

@ -0,0 +1,6 @@
contract test {
}
// ====
// compileViaYul: also
// ----
// i_am_not_there() -> FAILURE

View File

@ -0,0 +1,9 @@
contract test {
function f() public { }
function g() public { revert(); }
function h() public { assert(false); }
}
// ----
// f() ->
// g() -> FAILURE
// h() -> FAILURE

View File

@ -33,6 +33,9 @@ contract C {
function p() public returns (string memory, uint, string memory) {
return ("any", 42, "any");
}
function q(uint a) public returns (uint d) {
return a * 7;
}
}
// ----
// constructor(): 3 ->
@ -51,3 +54,5 @@ contract C {
// n() -> 0x20, 3, "any"
// o() -> 0x40, 0x80, 3, "any", 3, "any"
// p() -> 0x60, 0x2a, 0xa0, 3, "any", 3, "any"
// q(uint256): 0 -> 0
// q(uint256): 99 -> 693