mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Explicit conversion from int to Enum
This commit is contained in:
parent
9dedbb4154
commit
8e9a9ad5e9
@ -1039,6 +1039,23 @@ BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay)
|
|||||||
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
|
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit };
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
a = 2;
|
||||||
|
b = ActionChoices(a);
|
||||||
|
}
|
||||||
|
uint256 a;
|
||||||
|
ActionChoices b;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay)
|
BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user