Correcting and testing enum member access

This commit is contained in:
Lefteris Karapetsas 2015-02-12 15:19:04 +01:00
parent 60e839954e
commit d8535eb4ea

View File

@ -991,11 +991,11 @@ BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big)
})"; })";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
} }
BOOST_AUTO_TEST_CASE(enum_member_access) BOOST_AUTO_TEST_CASE(enum_member_access)
{ {
char const* text = R"( char const* text = R"(
contract test { contract test {
struct foo { uint256 x;}
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; enum ActionChoices { GoLeft, GoRight, GoStraight, Sit };
function test() function test()
{ {
@ -1007,6 +1007,21 @@ BOOST_AUTO_TEST_CASE(enum_member_access)
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text)); BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
} }
BOOST_AUTO_TEST_CASE(enum_invalid_member_access)
{
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit };
function test()
{
choices = ActionChoices.RunAroundWavingYourHands;
}
ActionChoices choices;
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }