mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
parent
984b8ac1b5
commit
f967623a5b
@ -3314,6 +3314,57 @@ BOOST_AUTO_TEST_CASE(using_enums)
|
||||
BOOST_CHECK(callContractFunction("getChoice()") == encodeArgs(2));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(using_contract_enums_with_explicit_contract_name)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
enum Choice { A, B, C }
|
||||
function answer () returns (test.Choice _ret)
|
||||
{
|
||||
_ret = test.Choice.B;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("answer()") == encodeArgs(1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(using_inherited_enum)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract base {
|
||||
enum Choice { A, B, C }
|
||||
}
|
||||
|
||||
contract test is base {
|
||||
function answer () returns (Choice _ret)
|
||||
{
|
||||
_ret = Choice.B;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("answer()") == encodeArgs(1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(using_inherited_enum_excplicitly)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract base {
|
||||
enum Choice { A, B, C }
|
||||
}
|
||||
|
||||
contract test is base {
|
||||
function answer () returns (base.Choice _ret)
|
||||
{
|
||||
_ret = base.Choice.B;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("answer()") == encodeArgs(1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(constructing_enums_from_ints)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
@ -1500,6 +1500,23 @@ BOOST_AUTO_TEST_CASE(enum_duplicate_values)
|
||||
BOOST_CHECK(expectError(text) == Error::Type::DeclarationError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(enum_name_resolution_under_current_contract_name)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract A {
|
||||
enum Foo {
|
||||
First,
|
||||
Second
|
||||
}
|
||||
|
||||
function a() {
|
||||
A.Foo;
|
||||
}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(private_visibility)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user