mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Enums NameAndTypeResolution - WIP
- Also adding an EndToEnd enum test
This commit is contained in:
parent
850350e7bc
commit
60e839954e
@ -2499,6 +2499,26 @@ BOOST_AUTO_TEST_CASE(struct_copy_via_local)
|
|||||||
BOOST_CHECK(callContractFunction("test()") == encodeArgs(true));
|
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()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -991,6 +991,21 @@ 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)
|
||||||
|
{
|
||||||
|
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()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user