Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New semantic tests extracted #6888

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions test/libsolidity/SolidityEndToEndTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way: for this particular test here, it's not a problem and I don't really mind, but this command actually tests every value between 0 and 100, whereas the extracted test only checks two values, namely 0 and 99.

So actually tests involving testContractAgainstCppOnRange should probably stay in SolidityEndToEndTest.cpp.

But yeah, in this particular case, it really doesn't matter, if the full range is checked or not, so it's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I will keep in my mind for future changes

}

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"(
Expand Down
6 changes: 6 additions & 0 deletions test/libsolidity/semanticTests/empty_contract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
contract test {
}
// ====
// compileViaYul: also
// ----
// i_am_not_there() -> FAILURE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
contract test {
function f() public { }
function g() public { revert(); }
function h() public { assert(false); }
}
// ----
// f() ->
// g() -> FAILURE
// h() -> FAILURE
5 changes: 5 additions & 0 deletions test/libsolidity/semanticTests/smoke_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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