aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-01-21 02:11:22 +0800
committerchriseth <c@ethdev.com>2017-01-21 02:22:39 +0800
commitdf4ef74199392e9b29823d68e6a58dabd490e037 (patch)
treeb7cb804f1f57c5b2341c33b18c969e859e52e93a /test/libsolidity
parent12b002b3b8575539f332c30691e880bcc2fac5bc (diff)
downloaddexon-solidity-df4ef74199392e9b29823d68e6a58dabd490e037.tar.gz
dexon-solidity-df4ef74199392e9b29823d68e6a58dabd490e037.tar.zst
dexon-solidity-df4ef74199392e9b29823d68e6a58dabd490e037.zip
Add tests for internal constructor.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp10
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp26
2 files changed, 36 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 19161831..63a5828e 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2505,6 +2505,16 @@ BOOST_AUTO_TEST_CASE(constructor_argument_overriding)
BOOST_CHECK(callContractFunction("getA()") == encodeArgs(3));
}
+BOOST_AUTO_TEST_CASE(internal_constructor)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function C() internal {}
+ }
+ )";
+ BOOST_CHECK(compileAndRunWithoutCheck(sourceCode, 0, "C").empty());
+}
+
BOOST_AUTO_TEST_CASE(function_modifier)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 9f6ea2b3..edb57b0d 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -4899,6 +4899,32 @@ BOOST_AUTO_TEST_CASE(assignment_to_constant)
CHECK_ERROR(text, TypeError, "Cannot assign to a constant variable.");
}
+BOOST_AUTO_TEST_CASE(inconstructible_internal_constructor)
+{
+ char const* text = R"(
+ contract C {
+ function C() internal {}
+ }
+ contract D {
+ function f() { var x = new C(); }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Contract with internal constructor cannot be created directly.");
+}
+
+BOOST_AUTO_TEST_CASE(constructible_internal_constructor)
+{
+ char const* text = R"(
+ contract C {
+ function C() internal {}
+ }
+ contract D is C {
+ function D() { }
+ }
+ )";
+ success(text);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}