Addressing issues with Enums in Solidity

This commit is contained in:
Lefteris Karapetsas 2015-02-13 22:52:04 +01:00
parent afc328210e
commit 9dedbb4154
2 changed files with 3 additions and 20 deletions

View File

@ -1061,13 +1061,6 @@ BOOST_AUTO_TEST_CASE(enum_duplicate_values)
char const* text = R"( char const* text = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoLeft, Sit }; enum ActionChoices { GoLeft, GoRight, GoLeft, Sit };
function test()
{
a = 1;
b = 2;
}
uint256 a;
uint64 b;
} }
)"; )";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);

View File

@ -703,14 +703,14 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expression
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); BOOST_CHECK_NO_THROW(parseTextExplainError(text));
} }
BOOST_AUTO_TEST_CASE(enum_declaration) BOOST_AUTO_TEST_CASE(enum_valid_declaration)
{ {
char const* text = R"( char const* text = R"(
contract c { contract c {
enum foo { WARNING, NOTICE, ERROR, CRITICAL }; enum validEnum { Value1, Value2, Value3, Value4 };
function c () function c ()
{ {
a = foo.CRITICAL; a = foo.Value3;
} }
uint256 a; uint256 a;
})"; })";
@ -722,11 +722,6 @@ BOOST_AUTO_TEST_CASE(empty_enum_declaration)
char const* text = R"( char const* text = R"(
contract c { contract c {
enum foo { }; enum foo { };
function c ()
{
a = 5;
}
uint256 a;
})"; })";
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); BOOST_CHECK_NO_THROW(parseTextExplainError(text));
} }
@ -736,11 +731,6 @@ BOOST_AUTO_TEST_CASE(malformed_enum_declaration)
char const* text = R"( char const* text = R"(
contract c { contract c {
enum foo { WARNING,}; enum foo { WARNING,};
function c ()
{
a = foo.CRITICAL;
}
uint256 a;
})"; })";
BOOST_CHECK_THROW(parseText(text), ParserError); BOOST_CHECK_THROW(parseText(text), ParserError);
} }