Browse Source

two more tests

style fixes
cl-refactor
Liana Husikyan 10 years ago
parent
commit
8b14b4f4d1
  1. 2
      libsolidity/AST.cpp
  2. 38
      test/SolidityNameAndTypeResolution.cpp

2
libsolidity/AST.cpp

@ -431,7 +431,7 @@ void EventDefinition::checkTypeRequirements()
if (!var->getType()->canLiveOutsideStorage()) if (!var->getType()->canLiveOutsideStorage())
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage.")); BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
if (!var->getType()->externalType()) if (!var->getType()->externalType())
BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed for Events")); BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed as event parameter type."));
} }
if (numIndexed > 3) if (numIndexed > 3)
BOOST_THROW_EXCEPTION(createTypeError("More than 3 indexed arguments for event.")); BOOST_THROW_EXCEPTION(createTypeError("More than 3 indexed arguments for event."));

38
test/SolidityNameAndTypeResolution.cpp

@ -418,9 +418,23 @@ BOOST_AUTO_TEST_CASE(function_external_types)
} }
} }
BOOST_AUTO_TEST_CASE(function_external_call_conversion) BOOST_AUTO_TEST_CASE(function_external_call_allowed_conversion)
{ {
char const* sourceCode = R"( char const* text = R"(
contract C {}
contract Test {
function externalCall() {
C arg;
this.g(arg);
}
function g (C c) external {}
})";
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
BOOST_AUTO_TEST_CASE(function_external_call_not_allowed_conversion)
{
char const* text = R"(
contract C {} contract C {}
contract Test { contract Test {
function externalCall() { function externalCall() {
@ -429,10 +443,26 @@ BOOST_AUTO_TEST_CASE(function_external_call_conversion)
} }
function g (C c) external {} function g (C c) external {}
})"; })";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
BOOST_AUTO_TEST_CASE(function_internal_allowed_conversion)
{
char const* text = R"(
contract C {
uint a;
}
contract Test {
C a;
function g (C c) {}
function internalCall() {
g(a);
}
})";
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
} }
BOOST_AUTO_TEST_CASE(function_internal_call_conversion) BOOST_AUTO_TEST_CASE(function_internal_not_allowed_conversion)
{ {
char const* text = R"( char const* text = R"(
contract C { contract C {

Loading…
Cancel
Save