Skip to content

Commit

Permalink
Enum panic test for pre-byzantium.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Oct 19, 2020
1 parent 14933b7 commit 2ad6d84
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
contract test {
enum ActionChoices {GoLeft, GoRight, GoStraight}

constructor() {}

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);
}

function getChoiceFromNegativeLiteral() public returns (uint256 d) {
choice = ActionChoices(-1);
d = uint256(choice);
}

ActionChoices choice;
}

// ====
// EVMVersion: <byzantium
// compileViaYul: also
// ----
// getChoiceExp(uint256): 3 -> FAILURE # These should throw #
// getChoiceFromSigned(int256): -1 -> FAILURE
// getChoiceFromNegativeLiteral() -> FAILURE
// getChoiceExp(uint256): 2 -> 2 # These should work #
// getChoiceExp(uint256): 0 -> 0

0 comments on commit 2ad6d84

Please sign in to comment.