2020-03-09 21:14:07 +00:00
|
|
|
contract test {
|
|
|
|
enum ActionChoices {GoLeft, GoRight, GoStraight}
|
|
|
|
|
2020-06-23 12:14:24 +00:00
|
|
|
constructor() {}
|
2020-03-09 21:14:07 +00:00
|
|
|
|
|
|
|
function getChoiceExp(uint256 x) public returns (uint256 d) {
|
|
|
|
choice = ActionChoices(x);
|
|
|
|
d = uint256(choice);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChoiceFromSigned(int256 x) public returns (uint256 d) {
|
|
|
|
choice = ActionChoices(x);
|
|
|
|
d = uint256(choice);
|
|
|
|
}
|
|
|
|
|
2020-11-06 16:39:44 +00:00
|
|
|
function getChoiceFromMax() public returns (uint256 d) {
|
|
|
|
choice = ActionChoices(type(uint).max);
|
2020-03-09 21:14:07 +00:00
|
|
|
d = uint256(choice);
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionChoices choice;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
2020-10-13 11:28:39 +00:00
|
|
|
// EVMVersion: >=byzantium
|
2020-03-09 21:14:07 +00:00
|
|
|
// ----
|
2020-11-06 16:39:44 +00:00
|
|
|
// getChoiceExp(uint256): 2 -> 2
|
2020-10-13 11:28:39 +00:00
|
|
|
// getChoiceExp(uint256): 3 -> FAILURE, hex"4e487b71", 33 # These should throw #
|
|
|
|
// getChoiceFromSigned(int256): -1 -> FAILURE, hex"4e487b71", 33
|
2020-11-06 16:39:44 +00:00
|
|
|
// getChoiceFromMax() -> FAILURE, hex"4e487b71", 33
|
2020-03-09 21:14:07 +00:00
|
|
|
// getChoiceExp(uint256): 2 -> 2 # These should work #
|
|
|
|
// getChoiceExp(uint256): 0 -> 0
|