mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6888 from anurag-git/anurag_semantic_test_update
New semantic tests extracted
This commit is contained in:
commit
bd1f65d609
@ -64,47 +64,6 @@ int constexpr roundTo32(int _num)
|
|||||||
return (_num + 31) / 32 * 32;
|
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)
|
BOOST_AUTO_TEST_CASE(exp_operator)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
|
6
test/libsolidity/semanticTests/empty_contract.sol
Normal file
6
test/libsolidity/semanticTests/empty_contract.sol
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
contract test {
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// i_am_not_there() -> FAILURE
|
@ -0,0 +1,9 @@
|
|||||||
|
contract test {
|
||||||
|
function f() public { }
|
||||||
|
function g() public { revert(); }
|
||||||
|
function h() public { assert(false); }
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// f() ->
|
||||||
|
// g() -> FAILURE
|
||||||
|
// h() -> FAILURE
|
@ -33,6 +33,9 @@ contract C {
|
|||||||
function p() public returns (string memory, uint, string memory) {
|
function p() public returns (string memory, uint, string memory) {
|
||||||
return ("any", 42, "any");
|
return ("any", 42, "any");
|
||||||
}
|
}
|
||||||
|
function q(uint a) public returns (uint d) {
|
||||||
|
return a * 7;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// constructor(): 3 ->
|
// constructor(): 3 ->
|
||||||
@ -51,3 +54,5 @@ contract C {
|
|||||||
// n() -> 0x20, 3, "any"
|
// n() -> 0x20, 3, "any"
|
||||||
// o() -> 0x40, 0x80, 3, "any", 3, "any"
|
// o() -> 0x40, 0x80, 3, "any", 3, "any"
|
||||||
// p() -> 0x60, 0x2a, 0xa0, 3, "any", 3, "any"
|
// p() -> 0x60, 0x2a, 0xa0, 3, "any", 3, "any"
|
||||||
|
// q(uint256): 0 -> 0
|
||||||
|
// q(uint256): 99 -> 693
|
||||||
|
Loading…
Reference in New Issue
Block a user