From 4684c81aaa27f177931bb8ffe837e9edc8a4dca0 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 22 Nov 2022 07:32:47 +0100 Subject: testsuite/pyunit/libghdl: add tests for enums --- testsuite/pyunit/libghdl/Comments.py | 21 +++++++++++++++++++++ testsuite/pyunit/libghdl/enum.vhdl | 6 ++++++ testsuite/pyunit/libghdl/enum_fail.vhdl | 6 ++++++ testsuite/pyunit/libghdl/enumlit_1.vhdl | 8 ++++++++ testsuite/pyunit/libghdl/enumlit_2.vhdl | 8 ++++++++ testsuite/pyunit/libghdl/enumlit_fail.vhdl | 8 ++++++++ 6 files changed, 57 insertions(+) create mode 100644 testsuite/pyunit/libghdl/enum.vhdl create mode 100644 testsuite/pyunit/libghdl/enum_fail.vhdl create mode 100644 testsuite/pyunit/libghdl/enumlit_1.vhdl create mode 100644 testsuite/pyunit/libghdl/enumlit_2.vhdl create mode 100644 testsuite/pyunit/libghdl/enumlit_fail.vhdl diff --git a/testsuite/pyunit/libghdl/Comments.py b/testsuite/pyunit/libghdl/Comments.py index 82da89693..46b5956f4 100644 --- a/testsuite/pyunit/libghdl/Comments.py +++ b/testsuite/pyunit/libghdl/Comments.py @@ -61,6 +61,8 @@ class Instantiate(TestCase): defk = nodes.Get_Kind(tdef) if defk == nodes.Iir_Kind.Record_Type_Definition: self.checkFlist(nodes.Get_Elements_Declaration_List(tdef)) + elif defk == nodes.Iir_Kind.Enumeration_Type_Definition: + self.checkFlist(nodes.Get_Enumeration_Literal_List(tdef)) decl = nodes.Get_Chain(decl) def checkConc(self, first) -> None: @@ -222,4 +224,23 @@ class Instantiate(TestCase): def test_element_2(self) -> None: self.checkFile(self._root / "element_2.vhdl") + @expectedFailure + def test_enum_fail(self) -> None: + self.checkFile(self._root / "enum_fail.vhdl") + + def test_enum(self) -> None: + self.checkFile(self._root / "enum.vhdl") + + @expectedFailure + def test_enumlit_fail(self) -> None: + self.checkFile(self._root / "enumlit_fail.vhdl") + + def test_enumlit_1(self) -> None: + self.checkFile(self._root / "enumlit_1.vhdl") + + def test_enumlit_2(self) -> None: + self.checkFile(self._root / "enumlit_2.vhdl") + +# TODO: subprograms, subprogram parameters +# TODO: first comment # Empty line before to easy cut & put diff --git a/testsuite/pyunit/libghdl/enum.vhdl b/testsuite/pyunit/libghdl/enum.vhdl new file mode 100644 index 000000000..72c460269 --- /dev/null +++ b/testsuite/pyunit/libghdl/enum.vhdl @@ -0,0 +1,6 @@ +package p is + constant c : natural := 1; + + -- Comment for :state_t: + type state_t is (s1, s2, s3); +end p; diff --git a/testsuite/pyunit/libghdl/enum_fail.vhdl b/testsuite/pyunit/libghdl/enum_fail.vhdl new file mode 100644 index 000000000..ec8a1cb79 --- /dev/null +++ b/testsuite/pyunit/libghdl/enum_fail.vhdl @@ -0,0 +1,6 @@ +package p is + constant c : natural := 1; + + -- Comment + type state_t is (s1, s2, s3); +end p; diff --git a/testsuite/pyunit/libghdl/enumlit_1.vhdl b/testsuite/pyunit/libghdl/enumlit_1.vhdl new file mode 100644 index 000000000..c9b923051 --- /dev/null +++ b/testsuite/pyunit/libghdl/enumlit_1.vhdl @@ -0,0 +1,8 @@ +package p is + type state_t is + ( + -- Comment for :s1: + s1, + s2, + s3); +end p; diff --git a/testsuite/pyunit/libghdl/enumlit_2.vhdl b/testsuite/pyunit/libghdl/enumlit_2.vhdl new file mode 100644 index 000000000..44aa71d7d --- /dev/null +++ b/testsuite/pyunit/libghdl/enumlit_2.vhdl @@ -0,0 +1,8 @@ +package p is + type state_t is + ( + s1, + s2, + -- Comment for :s3: + s3); +end p; diff --git a/testsuite/pyunit/libghdl/enumlit_fail.vhdl b/testsuite/pyunit/libghdl/enumlit_fail.vhdl new file mode 100644 index 000000000..36a200402 --- /dev/null +++ b/testsuite/pyunit/libghdl/enumlit_fail.vhdl @@ -0,0 +1,8 @@ +package p is + type state_t is + ( + -- Comment + s1, + s2, + s3); +end p; -- cgit v1.2.3