mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Cleaner solution to provide standard sources.
This commit is contained in:
parent
f9109f2eea
commit
77374a46ce
@ -35,6 +35,8 @@ namespace test
|
||||
class InterfaceChecker
|
||||
{
|
||||
public:
|
||||
InterfaceChecker(): m_compilerStack(false) {}
|
||||
|
||||
void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString)
|
||||
{
|
||||
try
|
||||
|
@ -1862,6 +1862,21 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor)
|
||||
BOOST_CHECK(callContractFunction("getData()") == encodeArgs(4 | 2));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(use_std_lib)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
import "mortal";
|
||||
contract Icarus is mortal { }
|
||||
)";
|
||||
u256 amount(130);
|
||||
u160 address(23);
|
||||
compileAndRun(sourceCode, amount, "Icarus");
|
||||
u256 balanceBefore = m_state.balance(m_sender);
|
||||
BOOST_CHECK(callContractFunction("kill()") == bytes());
|
||||
BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
|
||||
BOOST_CHECK(m_state.balance(m_sender) > balanceBefore);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ namespace test
|
||||
class DocumentationChecker
|
||||
{
|
||||
public:
|
||||
DocumentationChecker(): m_compilerStack(false) {}
|
||||
|
||||
void checkNatspec(std::string const& _code,
|
||||
std::string const& _expectedDocumentationString,
|
||||
bool _userDocumentation)
|
||||
|
@ -45,10 +45,12 @@ public:
|
||||
|
||||
bytes const& compileAndRun(std::string const& _sourceCode, u256 const& _value = 0, std::string const& _contractName = "")
|
||||
{
|
||||
dev::solidity::CompilerStack compiler;
|
||||
// add standard sources only if contract name is given
|
||||
dev::solidity::CompilerStack compiler(!_contractName.empty());
|
||||
try
|
||||
{
|
||||
compiler.compile(_sourceCode, m_optimize);
|
||||
compiler.addSource("", _sourceCode);
|
||||
compiler.compile(m_optimize);
|
||||
}
|
||||
catch(boost::exception const& _e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user