From 0d884952ea74a9dcdf2a54b933cdfd207b20ef6b Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sun, 29 Dec 2024 11:08:54 +0000 Subject: [PATCH] Issue#1366: Added tests for subprogram instantiation structure rules. --- .../rule_001_test_input.fixed.vhd | 26 ++++++++++ .../rule_001_test_input.vhd | 26 ++++++++++ .../rule_002_test_input.fixed.vhd | 26 ++++++++++ .../rule_002_test_input.vhd | 26 ++++++++++ .../rule_003_test_input.fixed.vhd | 26 ++++++++++ .../rule_003_test_input.vhd | 26 ++++++++++ .../rule_004_test_input.fixed.vhd | 26 ++++++++++ .../rule_004_test_input.vhd | 26 ++++++++++ .../rule_005_test_input.fixed.vhd | 26 ++++++++++ .../rule_005_test_input.vhd | 26 ++++++++++ .../subprogram_instantiation/test_rule_001.py | 48 +++++++++++++++++++ .../subprogram_instantiation/test_rule_002.py | 48 +++++++++++++++++++ .../subprogram_instantiation/test_rule_003.py | 48 +++++++++++++++++++ .../subprogram_instantiation/test_rule_004.py | 48 +++++++++++++++++++ .../subprogram_instantiation/test_rule_005.py | 48 +++++++++++++++++++ 15 files changed, 500 insertions(+) create mode 100644 tests/subprogram_instantiation/rule_001_test_input.fixed.vhd create mode 100644 tests/subprogram_instantiation/rule_001_test_input.vhd create mode 100644 tests/subprogram_instantiation/rule_002_test_input.fixed.vhd create mode 100644 tests/subprogram_instantiation/rule_002_test_input.vhd create mode 100644 tests/subprogram_instantiation/rule_003_test_input.fixed.vhd create mode 100644 tests/subprogram_instantiation/rule_003_test_input.vhd create mode 100644 tests/subprogram_instantiation/rule_004_test_input.fixed.vhd create mode 100644 tests/subprogram_instantiation/rule_004_test_input.vhd create mode 100644 tests/subprogram_instantiation/rule_005_test_input.fixed.vhd create mode 100644 tests/subprogram_instantiation/rule_005_test_input.vhd create mode 100644 tests/subprogram_instantiation/test_rule_001.py create mode 100644 tests/subprogram_instantiation/test_rule_002.py create mode 100644 tests/subprogram_instantiation/test_rule_003.py create mode 100644 tests/subprogram_instantiation/test_rule_004.py create mode 100644 tests/subprogram_instantiation/test_rule_005.py diff --git a/tests/subprogram_instantiation/rule_001_test_input.fixed.vhd b/tests/subprogram_instantiation/rule_001_test_input.fixed.vhd new file mode 100644 index 00000000..1fbbc613 --- /dev/null +++ b/tests/subprogram_instantiation/rule_001_test_input.fixed.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function + my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc + is new my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_001_test_input.vhd b/tests/subprogram_instantiation/rule_001_test_input.vhd new file mode 100644 index 00000000..12b97518 --- /dev/null +++ b/tests/subprogram_instantiation/rule_001_test_input.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function + my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure + my_proc is new my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_002_test_input.fixed.vhd b/tests/subprogram_instantiation/rule_002_test_input.fixed.vhd new file mode 100644 index 00000000..995c289b --- /dev/null +++ b/tests/subprogram_instantiation/rule_002_test_input.fixed.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function my_func + is new my_generic_func + generic map ( + test => 2 + ); + + procedure + my_proc is new my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_002_test_input.vhd b/tests/subprogram_instantiation/rule_002_test_input.vhd new file mode 100644 index 00000000..12b97518 --- /dev/null +++ b/tests/subprogram_instantiation/rule_002_test_input.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function + my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure + my_proc is new my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_003_test_input.fixed.vhd b/tests/subprogram_instantiation/rule_003_test_input.fixed.vhd new file mode 100644 index 00000000..d06df044 --- /dev/null +++ b/tests/subprogram_instantiation/rule_003_test_input.fixed.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function my_func is + new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is + new my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_003_test_input.vhd b/tests/subprogram_instantiation/rule_003_test_input.vhd new file mode 100644 index 00000000..704f8dbf --- /dev/null +++ b/tests/subprogram_instantiation/rule_003_test_input.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function my_func + is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc + is new my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_004_test_input.fixed.vhd b/tests/subprogram_instantiation/rule_004_test_input.fixed.vhd new file mode 100644 index 00000000..f4c0a910 --- /dev/null +++ b/tests/subprogram_instantiation/rule_004_test_input.fixed.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function my_func is new + my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new + my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_004_test_input.vhd b/tests/subprogram_instantiation/rule_004_test_input.vhd new file mode 100644 index 00000000..d06df044 --- /dev/null +++ b/tests/subprogram_instantiation/rule_004_test_input.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function my_func is + new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is + new my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_005_test_input.fixed.vhd b/tests/subprogram_instantiation/rule_005_test_input.fixed.vhd new file mode 100644 index 00000000..8d641475 --- /dev/null +++ b/tests/subprogram_instantiation/rule_005_test_input.fixed.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function my_func is new my_generic_func + + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/rule_005_test_input.vhd b/tests/subprogram_instantiation/rule_005_test_input.vhd new file mode 100644 index 00000000..f4c0a910 --- /dev/null +++ b/tests/subprogram_instantiation/rule_005_test_input.vhd @@ -0,0 +1,26 @@ + +package test is + + function my_func is new my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new my_generic_proc + generic map ( + test => 2 + ); + + function my_func is new + my_generic_func + generic map ( + test => 2 + ); + + procedure my_proc is new + my_generic_proc + generic map ( + test => 2 + ); + +end package test; diff --git a/tests/subprogram_instantiation/test_rule_001.py b/tests/subprogram_instantiation/test_rule_001.py new file mode 100644 index 00000000..8b5749a3 --- /dev/null +++ b/tests/subprogram_instantiation/test_rule_001.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import subprogram_instantiation + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_001_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_001_test_input.fixed.vhd"), lExpected) + + +class test_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_001(self): + oRule = subprogram_instantiation.rule_001() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "subprogram_instantiation") + self.assertEqual(oRule.identifier, "001") + + lExpected = [20] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_001(self): + oRule = subprogram_instantiation.rule_001() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/subprogram_instantiation/test_rule_002.py b/tests/subprogram_instantiation/test_rule_002.py new file mode 100644 index 00000000..27b1cf7d --- /dev/null +++ b/tests/subprogram_instantiation/test_rule_002.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import subprogram_instantiation + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_002_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_002_test_input.fixed.vhd"), lExpected) + + +class test_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_002(self): + oRule = subprogram_instantiation.rule_002() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "subprogram_instantiation") + self.assertEqual(oRule.identifier, "002") + + lExpected = [14] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_002(self): + oRule = subprogram_instantiation.rule_002() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/subprogram_instantiation/test_rule_003.py b/tests/subprogram_instantiation/test_rule_003.py new file mode 100644 index 00000000..deab8fcb --- /dev/null +++ b/tests/subprogram_instantiation/test_rule_003.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import subprogram_instantiation + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_003_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_003_test_input.fixed.vhd"), lExpected) + + +class test_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_003(self): + oRule = subprogram_instantiation.rule_003() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "subprogram_instantiation") + self.assertEqual(oRule.identifier, "003") + + lExpected = [14, 20] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_003(self): + oRule = subprogram_instantiation.rule_003() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/subprogram_instantiation/test_rule_004.py b/tests/subprogram_instantiation/test_rule_004.py new file mode 100644 index 00000000..23ce0e43 --- /dev/null +++ b/tests/subprogram_instantiation/test_rule_004.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import subprogram_instantiation + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_004_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_004_test_input.fixed.vhd"), lExpected) + + +class test_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_004(self): + oRule = subprogram_instantiation.rule_004() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "subprogram_instantiation") + self.assertEqual(oRule.identifier, "004") + + lExpected = [14, 20] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_004(self): + oRule = subprogram_instantiation.rule_004() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/subprogram_instantiation/test_rule_005.py b/tests/subprogram_instantiation/test_rule_005.py new file mode 100644 index 00000000..e31bd553 --- /dev/null +++ b/tests/subprogram_instantiation/test_rule_005.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import subprogram_instantiation + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_005_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_005_test_input.fixed.vhd"), lExpected) + + +class test_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_005(self): + oRule = subprogram_instantiation.rule_005() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "subprogram_instantiation") + self.assertEqual(oRule.identifier, "005") + + lExpected = [14, 20] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_005(self): + oRule = subprogram_instantiation.rule_005() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, [])