Enums NameAndTypeResolution - WIP

- Also adding an EndToEnd enum test
This commit is contained in:
Lefteris Karapetsas 2015-02-11 21:40:47 +01:00
parent 850350e7bc
commit 60e839954e
2 changed files with 35 additions and 0 deletions

View File

@ -2499,6 +2499,26 @@ BOOST_AUTO_TEST_CASE(struct_copy_via_local)
BOOST_CHECK(callContractFunction("test()") == encodeArgs(true));
}
BOOST_AUTO_TEST_CASE(using_enums)
{
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit };
function test()
{
choices = ActionChoices.GoStraight;
}
function getChoice() returns (uint d)
{
d = choices;
}
ActionChoices choices;
}
)";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("getChoice()") == encodeArgs(2));
}
BOOST_AUTO_TEST_SUITE_END()
}

View File

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