aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-05 03:38:45 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-05 03:38:45 +0800
commitbb0eb57c2f2eadb4cc4a88cd347b70fec7813887 (patch)
tree6dabbedb630a0bfcd9022e233a5f083955a5bef0 /test
parenta372941a442fe1029d212ebf7b097bdea7534fad (diff)
downloaddexon-solidity-bb0eb57c2f2eadb4cc4a88cd347b70fec7813887.tar.gz
dexon-solidity-bb0eb57c2f2eadb4cc4a88cd347b70fec7813887.tar.zst
dexon-solidity-bb0eb57c2f2eadb4cc4a88cd347b70fec7813887.zip
Constructors must be implemented if declared.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp50
1 files changed, 11 insertions, 39 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 37bbc2eb..aaf1a449 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -677,44 +677,6 @@ BOOST_AUTO_TEST_CASE(create_abstract_contract)
CHECK_ERROR(text, TypeError, "");
}
-BOOST_AUTO_TEST_CASE(abstract_contract_constructor_args_optional)
-{
- ASTPointer<SourceUnit> sourceUnit;
- char const* text = R"(
- contract BaseBase { function BaseBase(uint j); }
- contract base is BaseBase { function foo(); }
- contract derived is base {
- function derived(uint i) BaseBase(i){}
- function foo() {}
- }
- )";
- ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseAndAnalyse(text), "Parsing and name resolving failed");
- std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->nodes();
- BOOST_CHECK_EQUAL(nodes.size(), 4);
- ContractDefinition* derived = dynamic_cast<ContractDefinition*>(nodes[3].get());
- BOOST_REQUIRE(derived);
- BOOST_CHECK(!derived->annotation().unimplementedFunctions.empty());
-}
-
-BOOST_AUTO_TEST_CASE(abstract_contract_constructor_args_not_provided)
-{
- ASTPointer<SourceUnit> sourceUnit;
- char const* text = R"(
- contract BaseBase { function BaseBase(uint); }
- contract base is BaseBase { function foo(); }
- contract derived is base {
- function derived(uint) {}
- function foo() {}
- }
- )";
- ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseAndAnalyse(text), "Parsing and name resolving failed");
- std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->nodes();
- BOOST_CHECK_EQUAL(nodes.size(), 4);
- ContractDefinition* derived = dynamic_cast<ContractDefinition*>(nodes[3].get());
- BOOST_REQUIRE(derived);
- BOOST_CHECK(!derived->annotation().unimplementedFunctions.empty());
-}
-
BOOST_AUTO_TEST_CASE(redeclare_implemented_abstract_function_as_abstract)
{
ASTPointer<SourceUnit> sourceUnit;
@@ -5714,7 +5676,7 @@ BOOST_AUTO_TEST_CASE(interface_constructor)
function I();
}
)";
- CHECK_ERROR(text, TypeError, "Constructor cannot be defined in interfaces");
+ CHECK_ERROR_ALLOW_MULTI(text, TypeError, "Constructor cannot be defined in interfaces");
}
BOOST_AUTO_TEST_CASE(interface_functions)
@@ -6564,6 +6526,16 @@ BOOST_AUTO_TEST_CASE(builtin_reject_value)
CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
}
+BOOST_AUTO_TEST_CASE(constructor_without_implementation)
+{
+ char const* text = R"(
+ contract C {
+ function C();
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Constructor must be implemented if declared.");
+}
+
BOOST_AUTO_TEST_SUITE_END()
}