From 31425a1fc0a75d353d89744cc11d9fcfd4d2a4b1 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 14 Feb 2015 03:06:50 +0100 Subject: [PATCH 1/2] Some changes to enums. --- SolidityNameAndTypeResolution.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index ec49a42d1..d6e4ed516 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -1080,7 +1080,7 @@ BOOST_AUTO_TEST_CASE(enum_duplicate_values) enum ActionChoices { GoLeft, GoRight, GoLeft, Sit } } )"; - BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); + BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError); } BOOST_AUTO_TEST_SUITE_END() From 600b38224ea1592af9a8348b082abb996ee5ef76 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 14 Feb 2015 03:22:49 +0100 Subject: [PATCH 2/2] Forced cleanup for conversion to enum. --- SolidityEndToEndTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 2ef2b8038..0325c4c6a 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -2519,6 +2519,21 @@ BOOST_AUTO_TEST_CASE(using_enums) BOOST_CHECK(callContractFunction("getChoice()") == encodeArgs(2)); } +BOOST_AUTO_TEST_CASE(constructing_enums_from_ints) +{ + char const* sourceCode = R"( + contract c { + enum Truth { False, True } + function test() returns (uint) + { + return uint(Truth(uint8(0x701))); + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(1)); +} + BOOST_AUTO_TEST_SUITE_END() }