mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add more complex tests for interfaces
This commit is contained in:
parent
d5102c1db7
commit
5a71e4f1a7
@ -9266,6 +9266,41 @@ BOOST_AUTO_TEST_CASE(scientific_notation)
|
|||||||
BOOST_CHECK(callContractFunction("k()") == encodeArgs(u256(-25)));
|
BOOST_CHECK(callContractFunction("k()") == encodeArgs(u256(-25)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(interface)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
interface I {
|
||||||
|
event A();
|
||||||
|
function f() returns (bool);
|
||||||
|
function() payable;
|
||||||
|
}
|
||||||
|
|
||||||
|
contract A is I {
|
||||||
|
function f() returns (bool) {
|
||||||
|
return g();
|
||||||
|
}
|
||||||
|
|
||||||
|
function g() returns (bool) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function() payable {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f(address _interfaceAddress) returns (bool) {
|
||||||
|
I i = I(_interfaceAddress);
|
||||||
|
return i.f();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode, 0, "A");
|
||||||
|
u160 const recipient = m_contractAddress;
|
||||||
|
compileAndRun(sourceCode, 0, "C");
|
||||||
|
BOOST_CHECK(callContractFunction("f(address)", recipient) == encodeArgs(true));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5435,6 +5435,23 @@ BOOST_AUTO_TEST_CASE(using_interface)
|
|||||||
success(text);
|
success(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(using_interface_complex)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
interface I {
|
||||||
|
event A();
|
||||||
|
function f();
|
||||||
|
function g();
|
||||||
|
function();
|
||||||
|
}
|
||||||
|
contract C is I {
|
||||||
|
function f() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
success(text);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user