Browse Source

two more tests

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

2
libsolidity/AST.cpp

@ -431,7 +431,7 @@ void EventDefinition::checkTypeRequirements()
if (!var->getType()->canLiveOutsideStorage())
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
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)
BOOST_THROW_EXCEPTION(createTypeError("More than 3 indexed arguments for event."));

2
libsolidity/AST.h

@ -422,7 +422,7 @@ public:
void checkTypeRequirements();
/// @returns the external signature of the function
/// That consists of the name of the function followed by the types(external types if isExternalCall) of the
/// That consists of the name of the function followed by the types (external types if isExternalCall) of the
/// arguments separated by commas all enclosed in parentheses without any spaces.
std::string externalSignature(bool isExternalCall = false) const;

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 Test {
function externalCall() {
@ -429,10 +443,26 @@ BOOST_AUTO_TEST_CASE(function_external_call_conversion)
}
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"(
contract C {

Loading…
Cancel
Save