aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-11-22 07:32:47 +0100
committerTristan Gingold <tgingold@free.fr>2022-11-22 07:44:53 +0100
commit4684c81aaa27f177931bb8ffe837e9edc8a4dca0 (patch)
treed39dd5c734d5af026f77fb3a96d83d5dd7b5af79
parentcc505073525dd5ffe1bd05004a2fb79917680d68 (diff)
downloadghdl-4684c81aaa27f177931bb8ffe837e9edc8a4dca0.tar.gz
ghdl-4684c81aaa27f177931bb8ffe837e9edc8a4dca0.tar.bz2
ghdl-4684c81aaa27f177931bb8ffe837e9edc8a4dca0.zip
testsuite/pyunit/libghdl: add tests for enums
-rw-r--r--testsuite/pyunit/libghdl/Comments.py21
-rw-r--r--testsuite/pyunit/libghdl/enum.vhdl6
-rw-r--r--testsuite/pyunit/libghdl/enum_fail.vhdl6
-rw-r--r--testsuite/pyunit/libghdl/enumlit_1.vhdl8
-rw-r--r--testsuite/pyunit/libghdl/enumlit_2.vhdl8
-rw-r--r--testsuite/pyunit/libghdl/enumlit_fail.vhdl8
6 files changed, 57 insertions, 0 deletions
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;