From 47e42430f27c579e09157f3373238e3bbe8ab93e Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 10 Sep 2015 17:17:13 +0200 Subject: added type check if the type of the var decl is one of base contract type --- test/libsolidity/SolidityEndToEndTest.cpp | 11 ----------- test/libsolidity/SolidityNameAndTypeResolution.cpp | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 8f38adac..aa423330 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5230,17 +5230,6 @@ BOOST_AUTO_TEST_CASE(storage_string_as_mapping_key_without_variable) BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(2))); } -BOOST_AUTO_TEST_CASE(string_as_mapping_key) -{ - char const* sourceCode = R"( - contract Test { - function f() { var x = new Test(); } - } - )"; - - compileAndRun(sourceCode, 0, "Test"); -} - BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 9f352b36..2b343db3 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2194,6 +2194,18 @@ BOOST_AUTO_TEST_CASE(string_bytes_conversion) BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); } + +BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract) +{ + char const* sourceCode = R"( + contract Test { + function f() { var x = new Test(); } + } + )"; + + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit