From 27051dd201db5b37739cc17ef8cc6d1f50c1903f Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 10:57:32 +0000 Subject: [PATCH] Issue#1330 Added tests for new package instantiation naming rules. --- .../rule_600_test_input.vhd | 15 ++++++++++ .../rule_601_test_input.vhd | 15 ++++++++++ tests/package_instantiation/test_rule_600.py | 29 +++++++++++++++++++ tests/package_instantiation/test_rule_601.py | 29 +++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 tests/package_instantiation/rule_600_test_input.vhd create mode 100644 tests/package_instantiation/rule_601_test_input.vhd create mode 100644 tests/package_instantiation/test_rule_600.py create mode 100644 tests/package_instantiation/test_rule_601.py diff --git a/tests/package_instantiation/rule_600_test_input.vhd b/tests/package_instantiation/rule_600_test_input.vhd new file mode 100644 index 00000000..c0773271 --- /dev/null +++ b/tests/package_instantiation/rule_600_test_input.vhd @@ -0,0 +1,15 @@ + +package foo is new my_generic_pkg + generic map ( + g_my_generic => 2 + ); + +package pkg_foo is new my_generic_pkg + generic map ( + g_my_generic => 2 + ); + +package foo_pkg is new my_generic_pkg + generic map ( + g_my_generic => 2 + ); diff --git a/tests/package_instantiation/rule_601_test_input.vhd b/tests/package_instantiation/rule_601_test_input.vhd new file mode 100644 index 00000000..c0773271 --- /dev/null +++ b/tests/package_instantiation/rule_601_test_input.vhd @@ -0,0 +1,15 @@ + +package foo is new my_generic_pkg + generic map ( + g_my_generic => 2 + ); + +package pkg_foo is new my_generic_pkg + generic map ( + g_my_generic => 2 + ); + +package foo_pkg is new my_generic_pkg + generic map ( + g_my_generic => 2 + ); diff --git a/tests/package_instantiation/test_rule_600.py b/tests/package_instantiation/test_rule_600.py new file mode 100644 index 00000000..36340416 --- /dev/null +++ b/tests/package_instantiation/test_rule_600.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import package_instantiation + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_600_test_input.vhd")) + + +class test_package_instantiation_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_600(self): + oRule = package_instantiation.rule_600() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "package_instantiation") + self.assertEqual(oRule.identifier, "600") + + lExpected = [2, 7] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/package_instantiation/test_rule_601.py b/tests/package_instantiation/test_rule_601.py new file mode 100644 index 00000000..f1ff34ce --- /dev/null +++ b/tests/package_instantiation/test_rule_601.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import package_instantiation + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_601_test_input.vhd")) + + +class test_package_instantiation_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_601(self): + oRule = package_instantiation.rule_601() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "package_instantiation") + self.assertEqual(oRule.identifier, "601") + + lExpected = [2, 12] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))