mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
test: add tests that witness issue #1311
This commit is contained in:
parent
e6098f0039
commit
8856adce8f
@ -3342,6 +3342,30 @@ BOOST_AUTO_TEST_CASE(using_enums)
|
|||||||
BOOST_CHECK(callContractFunction("getChoice()") == encodeArgs(2));
|
BOOST_CHECK(callContractFunction("getChoice()") == encodeArgs(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(enum_explicit_overflow)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract test {
|
||||||
|
enum ActionChoices { GoLeft, GoRight, GoStraight }
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
function getChoiceExp(uint x) returns (uint d)
|
||||||
|
{
|
||||||
|
choice = ActionChoices(x);
|
||||||
|
d = uint256(choice);
|
||||||
|
}
|
||||||
|
ActionChoices choice;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
// These should throw
|
||||||
|
BOOST_CHECK(callContractFunction("getChoiceExp(uint256)", 3) == encodeArgs());
|
||||||
|
// These should work
|
||||||
|
BOOST_CHECK(callContractFunction("getChoiceExp(uint256)", 2) == encodeArgs(2));
|
||||||
|
BOOST_CHECK(callContractFunction("getChoiceExp(uint256)", 0) == encodeArgs(0));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(using_contract_enums_with_explicit_contract_name)
|
BOOST_AUTO_TEST_CASE(using_contract_enums_with_explicit_contract_name)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user