From ce29aac8ad52336de6534dbeb98b9ecc38da11fa Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 7 Aug 2018 13:35:23 +0100 Subject: [PATCH] Add more syntax tests for enums and interfaces/libraries --- .../syntaxTests/parsing/enum_from_interface.sol | 9 +++++++++ .../parsing/enum_from_interface_in_library.sol | 12 ++++++++++++ .../syntaxTests/parsing/enum_from_library.sol | 9 +++++++++ .../parsing/enum_inheritance_contract.sol | 9 +++++++++ .../parsing/enum_inheritance_interface.sol | 9 +++++++++ 5 files changed, 48 insertions(+) create mode 100644 test/libsolidity/syntaxTests/parsing/enum_from_interface.sol create mode 100644 test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol create mode 100644 test/libsolidity/syntaxTests/parsing/enum_from_library.sol create mode 100644 test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol create mode 100644 test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol b/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol new file mode 100644 index 000000000..0fe0fbaee --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol @@ -0,0 +1,9 @@ +interface I { + enum Direction { Left, Right } +} + +contract D { + function f() public pure returns (I.Direction) { + return I.Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol b/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol new file mode 100644 index 000000000..8d9003eb6 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol @@ -0,0 +1,12 @@ +interface I { + enum Direction { Left, Right } +} + +library L { + function f() public pure returns (I.Direction) { + return I.Direction.Left; + } + function g() internal pure returns (I.Direction) { + return I.Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_library.sol b/test/libsolidity/syntaxTests/parsing/enum_from_library.sol new file mode 100644 index 000000000..ab762a82b --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_from_library.sol @@ -0,0 +1,9 @@ +library L { + enum Direction { Left, Right } +} + +contract D { + function f() public pure returns (L.Direction) { + return L.Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol b/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol new file mode 100644 index 000000000..e5b98352b --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol @@ -0,0 +1,9 @@ +contract C { + enum Direction { Left, Right } +} + +contract D is C { + function f() public pure returns (Direction) { + return Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol b/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol new file mode 100644 index 000000000..758587445 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol @@ -0,0 +1,9 @@ +interface I { + enum Direction { Left, Right } +} + +contract D is I { + function f() public pure returns (Direction) { + return Direction.Left; + } +}