aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-08-07 20:43:12 +0800
committerchriseth <chris@ethereum.org>2018-08-07 21:04:17 +0800
commit34a711a14daf9874061a83401bf28a57b3abf1b1 (patch)
treeb77fd0d7bd9bdf49637f45ee5f63313dd74ef231 /test
parentce29aac8ad52336de6534dbeb98b9ecc38da11fa (diff)
downloaddexon-solidity-34a711a14daf9874061a83401bf28a57b3abf1b1.tar.gz
dexon-solidity-34a711a14daf9874061a83401bf28a57b3abf1b1.tar.zst
dexon-solidity-34a711a14daf9874061a83401bf28a57b3abf1b1.zip
Add endToEnd test for referencing enums
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 9c287e5e..c291c6d6 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -4577,6 +4577,50 @@ BOOST_AUTO_TEST_CASE(constructing_enums_from_ints)
ABI_CHECK(callContractFunction("test()"), encodeArgs(1));
}
+BOOST_AUTO_TEST_CASE(enum_referencing)
+{
+ char const* sourceCode = R"(
+ interface I {
+ enum Direction { A, B, Left, Right }
+ }
+ library L {
+ enum Direction { Left, Right }
+ function f() public pure returns (Direction) {
+ return Direction.Right;
+ }
+ function g() public pure returns (I.Direction) {
+ return I.Direction.Right;
+ }
+ }
+ contract C is I {
+ function f() public pure returns (Direction) {
+ return Direction.Right;
+ }
+ function g() public pure returns (I.Direction) {
+ return I.Direction.Right;
+ }
+ function h() public pure returns (L.Direction) {
+ return L.Direction.Right;
+ }
+ function x() public pure returns (L.Direction) {
+ return L.f();
+ }
+ function y() public pure returns (I.Direction) {
+ return L.g();
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "L");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
+ compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(3));
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
+ ABI_CHECK(callContractFunction("h()"), encodeArgs(1));
+ ABI_CHECK(callContractFunction("x()"), encodeArgs(1));
+ ABI_CHECK(callContractFunction("y()"), encodeArgs(3));
+}
+
BOOST_AUTO_TEST_CASE(inline_member_init)
{
char const* sourceCode = R"(