aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/pyunit/dom
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/pyunit/dom')
-rw-r--r--testsuite/pyunit/dom/AllSources.py23
-rw-r--r--testsuite/pyunit/dom/Expressions.py46
-rw-r--r--testsuite/pyunit/dom/Literals.py46
-rw-r--r--testsuite/pyunit/dom/Sanity.py50
-rw-r--r--testsuite/pyunit/dom/SimpleEntity.py90
-rw-r--r--testsuite/pyunit/dom/SimplePackage.py70
-rw-r--r--testsuite/pyunit/dom/__init__.py32
7 files changed, 276 insertions, 81 deletions
diff --git a/testsuite/pyunit/dom/AllSources.py b/testsuite/pyunit/dom/AllSources.py
deleted file mode 100644
index 7dabf1b10..000000000
--- a/testsuite/pyunit/dom/AllSources.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from sys import executable
-from subprocess import check_call, STDOUT
-from pathlib import Path
-from glob import glob
-from pytest import mark
-
-if __name__ == "__main__":
- print("ERROR: you called a testcase declaration file as an executable module.")
- print("Use: 'python -m unitest <testcase module>'")
- exit(1)
-
-
-@mark.parametrize(
- "file",
- glob(str(Path(__file__).resolve().parent.parent.parent / 'sanity' / '*' / '*.vhdl'), recursive=True)
-)
-@mark.xfail
-def test_AllVHDLSources(file):
- check_call([
- executable,
- str(Path(__file__).resolve().parent.parent.parent.parent / 'pyGHDL' / 'cli' / 'DOM.py'),
- file
- ], stderr=STDOUT)
diff --git a/testsuite/pyunit/dom/Expressions.py b/testsuite/pyunit/dom/Expressions.py
index a7afb30ba..f9c066f52 100644
--- a/testsuite/pyunit/dom/Expressions.py
+++ b/testsuite/pyunit/dom/Expressions.py
@@ -1,11 +1,43 @@
-from pathlib import Path
+# =============================================================================
+# ____ _ _ ____ _ _
+# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
+# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
+# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
+# |_| |___/
+# =============================================================================
+# Authors:
+# Patrick Lehmann
+#
+# Testsuite: Check libghdl IIR translation to DOM for expressions.
+#
+# License:
+# ============================================================================
+# Copyright (C) 2019-2021 Tristan Gingold
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# ============================================================================
+from pathlib import Path
from textwrap import dedent
from unittest import TestCase
from pyGHDL.dom.DesignUnit import Package
from pyGHDL.dom import Expression
-from pyGHDL.dom.NonStandard import Design, Document
+from pyGHDL.dom.NonStandard import Design, Document
from pyGHDL.dom.Symbol import SimpleObjectOrFunctionCallSymbol
from pyGHDL.dom.Object import Constant
from pyGHDL.dom.Expression import InverseExpression
@@ -20,13 +52,17 @@ class Expressions(TestCase):
_root = Path(__file__).resolve().parent.parent
def test_NotExpression(self):
- self._filename: Path = self._root / "{className}.vhdl".format(className=self.__class__.__name__)
+ self._filename: Path = self._root / "{className}.vhdl".format(
+ className=self.__class__.__name__
+ )
- sourceCode = dedent("""\
+ sourceCode = dedent(
+ """\
package package_1 is
constant c0 : boolean := not true;
end package;
- """)
+ """
+ )
with self._filename.open(mode="w", encoding="utf-8") as file:
file.write(sourceCode)
diff --git a/testsuite/pyunit/dom/Literals.py b/testsuite/pyunit/dom/Literals.py
index c542ebfe5..ebd702f5e 100644
--- a/testsuite/pyunit/dom/Literals.py
+++ b/testsuite/pyunit/dom/Literals.py
@@ -1,8 +1,40 @@
-from pathlib import Path
+# =============================================================================
+# ____ _ _ ____ _ _
+# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
+# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
+# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
+# |_| |___/
+# =============================================================================
+# Authors:
+# Patrick Lehmann
+#
+# Testsuite: Check libghdl IIR translation to DOM for literals.
+#
+# License:
+# ============================================================================
+# Copyright (C) 2019-2021 Tristan Gingold
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# ============================================================================
+from pathlib import Path
from textwrap import dedent
from unittest import TestCase
-from pyGHDL.dom.NonStandard import Design, Document
+from pyGHDL.dom.NonStandard import Design, Document
from pyGHDL.dom.Object import Constant
from pyGHDL.dom.Literal import IntegerLiteral
@@ -17,16 +49,20 @@ class Literals(TestCase):
_root = Path(__file__).resolve().parent.parent
def test_IntegerLiteral(self):
- self._filename: Path = self._root / "{className}.vhdl".format(className=self.__class__.__name__)
+ self._filename: Path = self._root / "{className}.vhdl".format(
+ className=self.__class__.__name__
+ )
- sourceCode = dedent("""\
+ sourceCode = dedent(
+ """\
package package_1 is
constant c0 : integer := 0;
constant c1 : integer := 1;
constant c2 : integer := 1024;
constant c3 : integer := 1048576;
end package;
- """)
+ """
+ )
expected = (0, 1, 1024, 1048576)
with self._filename.open(mode="w", encoding="utf-8") as file:
diff --git a/testsuite/pyunit/dom/Sanity.py b/testsuite/pyunit/dom/Sanity.py
new file mode 100644
index 000000000..10258c38c
--- /dev/null
+++ b/testsuite/pyunit/dom/Sanity.py
@@ -0,0 +1,50 @@
+# =============================================================================
+# ____ _ _ ____ _ _
+# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
+# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
+# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
+# |_| |___/
+# =============================================================================
+# Authors:
+# Unai Martinez-Corral
+#
+# Testsuite: Parse files from sanity checks
+#
+# License:
+# ============================================================================
+# Copyright (C) 2019-2021 Tristan Gingold
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# ============================================================================
+from sys import executable
+from subprocess import check_call, STDOUT
+from pathlib import Path
+from pytest import mark
+
+if __name__ == "__main__":
+ print("ERROR: you called a testcase declaration file as an executable module.")
+ print("Use: 'python -m unitest <testcase module>'")
+ exit(1)
+
+_TESTSUITE_ROOT = Path(__file__).parent.parent.parent.resolve()
+_GHDL_ROOT = _TESTSUITE_ROOT.parent
+
+
+@mark.xfail
+@mark.parametrize("file", [str(f) for f in _TESTSUITE_ROOT.glob("sanity/**/*.vhdl")])
+def test_AllVHDLSources(file):
+ check_call([executable, _GHDL_ROOT / "pyGHDL/cli/DOM.py", file], stderr=STDOUT)
diff --git a/testsuite/pyunit/dom/SimpleEntity.py b/testsuite/pyunit/dom/SimpleEntity.py
index 8199fe7cc..9ee55508c 100644
--- a/testsuite/pyunit/dom/SimpleEntity.py
+++ b/testsuite/pyunit/dom/SimpleEntity.py
@@ -1,46 +1,78 @@
-from pathlib import Path
+# =============================================================================
+# ____ _ _ ____ _ _
+# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
+# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
+# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
+# |_| |___/
+# =============================================================================
+# Authors:
+# Patrick Lehmann
+#
+# Testsuite: Check libghdl IIR translation with a simple entity.
+#
+# License:
+# ============================================================================
+# Copyright (C) 2019-2021 Tristan Gingold
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# ============================================================================
+from pathlib import Path
from unittest import TestCase
-from pyGHDL.dom.NonStandard import Design, Document
+from pyGHDL.dom.NonStandard import Design, Document
if __name__ == "__main__":
- print("ERROR: you called a testcase declaration file as an executable module.")
- print("Use: 'python -m unitest <testcase module>'")
- exit(1)
+ print("ERROR: you called a testcase declaration file as an executable module.")
+ print("Use: 'python -m unitest <testcase module>'")
+ exit(1)
class SimpleEntity(TestCase):
- _root = Path(__file__).resolve().parent.parent
- _filename : Path = _root / "SimpleEntity.vhdl"
+ _root = Path(__file__).resolve().parent.parent
+ _filename: Path = _root / "SimpleEntity.vhdl"
- def test_Design(self):
- design = Design()
+ def test_Design(self):
+ design = Design()
- self.assertIsNotNone(design)
+ self.assertIsNotNone(design)
- # def test_Library(self):
- # library = Library()
+ # def test_Library(self):
+ # library = Library()
- def test_Document(self):
- design = Design()
- document = Document(self._filename)
- design.Documents.append(document)
+ def test_Document(self):
+ design = Design()
+ document = Document(self._filename)
+ design.Documents.append(document)
- self.assertTrue(len(design.Documents) == 1)
+ self.assertTrue(len(design.Documents) == 1)
- def test_Entity(self):
- design = Design()
- document = Document(self._filename)
- design.Documents.append(document)
+ def test_Entity(self):
+ design = Design()
+ document = Document(self._filename)
+ design.Documents.append(document)
- self.assertEqual(len(design.Documents[0].Entities), 1)
- self.assertTrue(design.Documents[0].Entities[0].Name == "entity_1")
+ self.assertEqual(len(design.Documents[0].Entities), 1)
+ self.assertTrue(design.Documents[0].Entities[0].Name == "entity_1")
- def test_Architecture(self):
- design = Design()
- document = Document(self._filename)
- design.Documents.append(document)
+ def test_Architecture(self):
+ design = Design()
+ document = Document(self._filename)
+ design.Documents.append(document)
- self.assertEqual(len(design.Documents[0].Architectures), 1)
- self.assertTrue(design.Documents[0].Architectures[0].Name == "behav")
+ self.assertEqual(len(design.Documents[0].Architectures), 1)
+ self.assertTrue(design.Documents[0].Architectures[0].Name == "behav")
diff --git a/testsuite/pyunit/dom/SimplePackage.py b/testsuite/pyunit/dom/SimplePackage.py
index 5b16e74b8..399a676b4 100644
--- a/testsuite/pyunit/dom/SimplePackage.py
+++ b/testsuite/pyunit/dom/SimplePackage.py
@@ -1,31 +1,63 @@
-from pathlib import Path
+# =============================================================================
+# ____ _ _ ____ _ _
+# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
+# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
+# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
+# |_| |___/
+# =============================================================================
+# Authors:
+# Patrick Lehmann
+#
+# Testsuite: Check libghdl IIR translation with a simple package.
+#
+# License:
+# ============================================================================
+# Copyright (C) 2019-2021 Tristan Gingold
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# ============================================================================
+from pathlib import Path
from unittest import TestCase
-from pyGHDL.dom.NonStandard import Design, Document
+from pyGHDL.dom.NonStandard import Design, Document
if __name__ == "__main__":
- print("ERROR: you called a testcase declaration file as an executable module.")
- print("Use: 'python -m unitest <testcase module>'")
- exit(1)
+ print("ERROR: you called a testcase declaration file as an executable module.")
+ print("Use: 'python -m unitest <testcase module>'")
+ exit(1)
class SimplePackage(TestCase):
- _root = Path(__file__).resolve().parent.parent
- _filename : Path = _root / "SimplePackage.vhdl"
+ _root = Path(__file__).resolve().parent.parent
+ _filename: Path = _root / "SimplePackage.vhdl"
- def test_Package(self):
- design = Design()
- document = Document(self._filename)
- design.Documents.append(document)
+ def test_Package(self):
+ design = Design()
+ document = Document(self._filename)
+ design.Documents.append(document)
- self.assertEqual(len(design.Documents[0].Packages), 1)
- self.assertTrue(design.Documents[0].Packages[0].Name == "pack_1")
+ self.assertEqual(len(design.Documents[0].Packages), 1)
+ self.assertTrue(design.Documents[0].Packages[0].Name == "pack_1")
- def test_PackageBody(self):
- design = Design()
- document = Document(self._filename)
- design.Documents.append(document)
+ def test_PackageBody(self):
+ design = Design()
+ document = Document(self._filename)
+ design.Documents.append(document)
- self.assertEqual(len(design.Documents[0].PackageBodies), 1)
- self.assertTrue(design.Documents[0].PackageBodies[0].Name == "pack_1")
+ self.assertEqual(len(design.Documents[0].PackageBodies), 1)
+ self.assertTrue(design.Documents[0].PackageBodies[0].Name == "pack_1")
diff --git a/testsuite/pyunit/dom/__init__.py b/testsuite/pyunit/dom/__init__.py
index e69de29bb..4991df255 100644
--- a/testsuite/pyunit/dom/__init__.py
+++ b/testsuite/pyunit/dom/__init__.py
@@ -0,0 +1,32 @@
+# =============================================================================
+# ____ _ _ ____ _ _
+# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
+# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
+# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
+# |_| |___/
+# =============================================================================
+# Authors:
+# Patrick Lehmann
+#
+# Testsuite: Check libghdl IIR translation to DOM.
+#
+# License:
+# ============================================================================
+# Copyright (C) 2019-2021 Tristan Gingold
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# ============================================================================