From 7807bdf865e170e0d0761cf67ad4ba6a772bdff5 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:24:42 +0100 Subject: [PATCH 01/43] Issue#1285: Added case rules for protected type declarations. --- vsg/rules/protected_type/__init__.py | 5 +++++ vsg/rules/protected_type/rule_500.py | 31 ++++++++++++++++++++++++++++ vsg/rules/protected_type/rule_501.py | 31 ++++++++++++++++++++++++++++ vsg/rules/protected_type/rule_502.py | 31 ++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 vsg/rules/protected_type/__init__.py create mode 100644 vsg/rules/protected_type/rule_500.py create mode 100644 vsg/rules/protected_type/rule_501.py create mode 100644 vsg/rules/protected_type/rule_502.py diff --git a/vsg/rules/protected_type/__init__.py b/vsg/rules/protected_type/__init__.py new file mode 100644 index 00000000..f3535725 --- /dev/null +++ b/vsg/rules/protected_type/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +from .rule_500 import rule_500 +from .rule_501 import rule_501 +from .rule_502 import rule_502 diff --git a/vsg/rules/protected_type/rule_500.py b/vsg/rules/protected_type/rule_500.py new file mode 100644 index 00000000..0dbda424 --- /dev/null +++ b/vsg/rules/protected_type/rule_500.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_declaration.protected_keyword) + + +class rule_500(token_case): + """ + This rule checks the **protected** keyword has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + type sharedcounter is PROTECTED + + **Fix** + + .. code-block:: vhdl + + type sharedcounter is protected + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") diff --git a/vsg/rules/protected_type/rule_501.py b/vsg/rules/protected_type/rule_501.py new file mode 100644 index 00000000..97b99434 --- /dev/null +++ b/vsg/rules/protected_type/rule_501.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_declaration.end_keyword) + + +class rule_501(token_case): + """ + This rule checks the **end** keyword in **end protected** has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + END protected sharedcounter; + + **Fix** + + .. code-block:: vhdl + + end protected sharedcounter; + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") diff --git a/vsg/rules/protected_type/rule_502.py b/vsg/rules/protected_type/rule_502.py new file mode 100644 index 00000000..6e53cb36 --- /dev/null +++ b/vsg/rules/protected_type/rule_502.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_declaration.end_protected_keyword) + + +class rule_501(token_case): + """ + This rule checks the **protected** keyword in **end protected** has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + end PROTECTED sharedcounter; + + **Fix** + + .. code-block:: vhdl + + end protected sharedcounter; + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") From c91f6eefe41dc0bcaa4fc59d5564c2e8966bb20c Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:25:04 +0100 Subject: [PATCH 02/43] Issue#1285: Added case rules for protected type body declarations. --- vsg/rules/protected_type_body/__init__.py | 7 +++++ vsg/rules/protected_type_body/rule_500.py | 31 +++++++++++++++++++++++ vsg/rules/protected_type_body/rule_501.py | 31 +++++++++++++++++++++++ vsg/rules/protected_type_body/rule_502.py | 31 +++++++++++++++++++++++ vsg/rules/protected_type_body/rule_503.py | 31 +++++++++++++++++++++++ vsg/rules/protected_type_body/rule_504.py | 31 +++++++++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 vsg/rules/protected_type_body/__init__.py create mode 100644 vsg/rules/protected_type_body/rule_500.py create mode 100644 vsg/rules/protected_type_body/rule_501.py create mode 100644 vsg/rules/protected_type_body/rule_502.py create mode 100644 vsg/rules/protected_type_body/rule_503.py create mode 100644 vsg/rules/protected_type_body/rule_504.py diff --git a/vsg/rules/protected_type_body/__init__.py b/vsg/rules/protected_type_body/__init__.py new file mode 100644 index 00000000..90c0eaba --- /dev/null +++ b/vsg/rules/protected_type_body/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + +from .rule_500 import rule_500 +from .rule_501 import rule_501 +from .rule_502 import rule_502 +from .rule_503 import rule_503 +from .rule_504 import rule_504 diff --git a/vsg/rules/protected_type_body/rule_500.py b/vsg/rules/protected_type_body/rule_500.py new file mode 100644 index 00000000..6a96cd67 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_500.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_body.protected_keyword) + + +class rule_500(token_case): + """ + This rule checks the **protected** keyword in **protected body** has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + type sharedcounter is PROTECTED body + + **Fix** + + .. code-block:: vhdl + + type sharedcounter is protected body + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") diff --git a/vsg/rules/protected_type_body/rule_501.py b/vsg/rules/protected_type_body/rule_501.py new file mode 100644 index 00000000..091c7bd0 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_501.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_body.body_keyword) + + +class rule_501(token_case): + """ + This rule checks the **body** keyword in **protected body** has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + type sharedcounter is protected BODY + + **Fix** + + .. code-block:: vhdl + + type sharedcounter is protected body + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") diff --git a/vsg/rules/protected_type_body/rule_502.py b/vsg/rules/protected_type_body/rule_502.py new file mode 100644 index 00000000..1190d3c6 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_502.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_body.end_keyword) + + +class rule_502(token_case): + """ + This rule checks the **end** keyword in **end protected body** has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + END protected body sharedcounter; + + **Fix** + + .. code-block:: vhdl + + end protected body sharedcounter; + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") diff --git a/vsg/rules/protected_type_body/rule_503.py b/vsg/rules/protected_type_body/rule_503.py new file mode 100644 index 00000000..13920533 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_503.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_body.end_protected_keyword) + + +class rule_503(token_case): + """ + This rule checks the **protected** keyword in **end protected body** has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + end PROTECTED body sharedcounter; + + **Fix** + + .. code-block:: vhdl + + end protected body sharedcounter; + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") diff --git a/vsg/rules/protected_type_body/rule_504.py b/vsg/rules/protected_type_body/rule_504.py new file mode 100644 index 00000000..c06b85e1 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_504.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import token_case + +lTokens = [] +lTokens.append(token.protected_type_body.end_body_keyword) + + +class rule_504(token_case): + """ + This rule checks the **body** keyword in **end protected body** has proper case. + + |configuring_uppercase_and_lowercase_rules_link| + + **Violation** + + .. code-block:: vhdl + + end protected BODY sharedcounter; + + **Fix** + + .. code-block:: vhdl + + end protected body sharedcounter; + """ + + def __init__(self): + super().__init__(lTokens) + self.groups.append("case::keyword") From 7afd4e05f8e05a46e899740661fef2aec6c9899a Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:41:25 +0100 Subject: [PATCH 03/43] Issue#1285: Correction in protected_type_502 --- vsg/rules/protected_type/rule_502.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsg/rules/protected_type/rule_502.py b/vsg/rules/protected_type/rule_502.py index 6e53cb36..67186c2e 100644 --- a/vsg/rules/protected_type/rule_502.py +++ b/vsg/rules/protected_type/rule_502.py @@ -7,7 +7,7 @@ lTokens = [] lTokens.append(token.protected_type_declaration.end_protected_keyword) -class rule_501(token_case): +class rule_502(token_case): """ This rule checks the **protected** keyword in **end protected** has proper case. From 0b2e3cf3dbd7d008aac434ff23680332ff3c1428 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:41:55 +0100 Subject: [PATCH 04/43] Issue#1285: Added protected_type and protected_type_body to top-level rules object --- vsg/rules/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vsg/rules/__init__.py b/vsg/rules/__init__.py index 857cb57e..2d750b2c 100644 --- a/vsg/rules/__init__.py +++ b/vsg/rules/__init__.py @@ -154,6 +154,8 @@ from vsg.rules import pragma from vsg.rules import procedure from vsg.rules import procedure_call from vsg.rules import process +from vsg.rules import protected_type +from vsg.rules import protected_type_body from vsg.rules import ranges from vsg.rules import record_type_definition from vsg.rules import report_statement From 61470c0a673914d4b69c9c2b13cbf6261ab8387b Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:42:11 +0100 Subject: [PATCH 05/43] Issue#1285: Added tests for protected_type rules --- tests/protected_type/__init__.py | 0 .../rule_500_test_input.fixed_lower.vhd | 21 ++++++ .../rule_500_test_input.fixed_upper.vhd | 21 ++++++ tests/protected_type/rule_500_test_input.vhd | 21 ++++++ .../rule_501_test_input.fixed_lower.vhd | 21 ++++++ .../rule_501_test_input.fixed_upper.vhd | 21 ++++++ tests/protected_type/rule_501_test_input.vhd | 21 ++++++ .../rule_502_test_input.fixed_lower.vhd | 21 ++++++ .../rule_502_test_input.fixed_upper.vhd | 21 ++++++ tests/protected_type/rule_502_test_input.vhd | 21 ++++++ tests/protected_type/test_rule_500.py | 73 +++++++++++++++++++ tests/protected_type/test_rule_501.py | 73 +++++++++++++++++++ tests/protected_type/test_rule_502.py | 73 +++++++++++++++++++ 13 files changed, 408 insertions(+) create mode 100644 tests/protected_type/__init__.py create mode 100644 tests/protected_type/rule_500_test_input.fixed_lower.vhd create mode 100644 tests/protected_type/rule_500_test_input.fixed_upper.vhd create mode 100644 tests/protected_type/rule_500_test_input.vhd create mode 100644 tests/protected_type/rule_501_test_input.fixed_lower.vhd create mode 100644 tests/protected_type/rule_501_test_input.fixed_upper.vhd create mode 100644 tests/protected_type/rule_501_test_input.vhd create mode 100644 tests/protected_type/rule_502_test_input.fixed_lower.vhd create mode 100644 tests/protected_type/rule_502_test_input.fixed_upper.vhd create mode 100644 tests/protected_type/rule_502_test_input.vhd create mode 100644 tests/protected_type/test_rule_500.py create mode 100644 tests/protected_type/test_rule_501.py create mode 100644 tests/protected_type/test_rule_502.py diff --git a/tests/protected_type/__init__.py b/tests/protected_type/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/protected_type/rule_500_test_input.fixed_lower.vhd b/tests/protected_type/rule_500_test_input.fixed_lower.vhd new file mode 100644 index 00000000..7dabe0d3 --- /dev/null +++ b/tests/protected_type/rule_500_test_input.fixed_lower.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end protected; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end protected; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_500_test_input.fixed_upper.vhd b/tests/protected_type/rule_500_test_input.fixed_upper.vhd new file mode 100644 index 00000000..75d113e3 --- /dev/null +++ b/tests/protected_type/rule_500_test_input.fixed_upper.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is PROTECTED + end protected; + + type flag_pt is PROTECTED + end protected; + +end package test; + +architecture rtl of test is + + type flag_pt is PROTECTED + end protected; + + type flag_pt is PROTECTED + end protected; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_500_test_input.vhd b/tests/protected_type/rule_500_test_input.vhd new file mode 100644 index 00000000..e7cf593d --- /dev/null +++ b/tests/protected_type/rule_500_test_input.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + end protected; + + type flag_pt is PROTECTED + end protected; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + end protected; + + type flag_pt is PROTECTED + end protected; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_501_test_input.fixed_lower.vhd b/tests/protected_type/rule_501_test_input.fixed_lower.vhd new file mode 100644 index 00000000..7dabe0d3 --- /dev/null +++ b/tests/protected_type/rule_501_test_input.fixed_lower.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end protected; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end protected; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_501_test_input.fixed_upper.vhd b/tests/protected_type/rule_501_test_input.fixed_upper.vhd new file mode 100644 index 00000000..216e99e3 --- /dev/null +++ b/tests/protected_type/rule_501_test_input.fixed_upper.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + END protected; + + type flag_pt is protected + END protected; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + END protected; + + type flag_pt is protected + END protected; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_501_test_input.vhd b/tests/protected_type/rule_501_test_input.vhd new file mode 100644 index 00000000..ddb8a02d --- /dev/null +++ b/tests/protected_type/rule_501_test_input.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + END protected; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + END protected; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_502_test_input.fixed_lower.vhd b/tests/protected_type/rule_502_test_input.fixed_lower.vhd new file mode 100644 index 00000000..7dabe0d3 --- /dev/null +++ b/tests/protected_type/rule_502_test_input.fixed_lower.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end protected; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end protected; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_502_test_input.fixed_upper.vhd b/tests/protected_type/rule_502_test_input.fixed_upper.vhd new file mode 100644 index 00000000..e80d6a15 --- /dev/null +++ b/tests/protected_type/rule_502_test_input.fixed_upper.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + end PROTECTED; + + type flag_pt is protected + end PROTECTED; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + end PROTECTED; + + type flag_pt is protected + end PROTECTED; + +begin + +end architecture rtl; diff --git a/tests/protected_type/rule_502_test_input.vhd b/tests/protected_type/rule_502_test_input.vhd new file mode 100644 index 00000000..27fe3bea --- /dev/null +++ b/tests/protected_type/rule_502_test_input.vhd @@ -0,0 +1,21 @@ +package test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end PROTECTED; + +end package test; + +architecture rtl of test is + + type flag_pt is protected + end protected; + + type flag_pt is protected + end PROTECTED; + +begin + +end architecture rtl; diff --git a/tests/protected_type/test_rule_500.py b/tests/protected_type/test_rule_500.py new file mode 100644 index 00000000..a472b0b7 --- /dev/null +++ b/tests/protected_type/test_rule_500.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_500_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_500_lower(self): + oRule = protected_type.rule_500() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type") + self.assertEqual(oRule.identifier, "500") + + lExpected = [6, 16] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_500_upper(self): + oRule = protected_type.rule_500() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type") + self.assertEqual(oRule.identifier, "500") + + lExpected = [3, 13] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_500_lower(self): + oRule = protected_type.rule_500() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_500_upper(self): + oRule = protected_type.rule_500() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type/test_rule_501.py b/tests/protected_type/test_rule_501.py new file mode 100644 index 00000000..7bff2504 --- /dev/null +++ b/tests/protected_type/test_rule_501.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_501_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_501_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_501_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_501_lower(self): + oRule = protected_type.rule_501() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type") + self.assertEqual(oRule.identifier, "501") + + lExpected = [7, 17] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_501_upper(self): + oRule = protected_type.rule_501() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type") + self.assertEqual(oRule.identifier, "501") + + lExpected = [4, 14] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_501_lower(self): + oRule = protected_type.rule_501() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_501_upper(self): + oRule = protected_type.rule_501() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type/test_rule_502.py b/tests/protected_type/test_rule_502.py new file mode 100644 index 00000000..b345aeba --- /dev/null +++ b/tests/protected_type/test_rule_502.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_502_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_502_lower(self): + oRule = protected_type.rule_502() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type") + self.assertEqual(oRule.identifier, "502") + + lExpected = [7, 17] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_502_upper(self): + oRule = protected_type.rule_502() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type") + self.assertEqual(oRule.identifier, "502") + + lExpected = [4, 14] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_502_lower(self): + oRule = protected_type.rule_502() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_502_upper(self): + oRule = protected_type.rule_502() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) From 218e4bbbcccf293b2323031b816159102066ef7a Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:49:39 +0100 Subject: [PATCH 06/43] Issue#1285: Whitespace changes in test cases. --- tests/protected_type/rule_500_test_input.fixed_lower.vhd | 1 + tests/protected_type/rule_500_test_input.fixed_upper.vhd | 1 + tests/protected_type/rule_500_test_input.vhd | 1 + tests/protected_type/rule_501_test_input.fixed_lower.vhd | 1 + tests/protected_type/rule_501_test_input.fixed_upper.vhd | 1 + tests/protected_type/rule_501_test_input.vhd | 1 + tests/protected_type/rule_502_test_input.fixed_lower.vhd | 1 + tests/protected_type/rule_502_test_input.fixed_upper.vhd | 1 + tests/protected_type/rule_502_test_input.vhd | 1 + 9 files changed, 9 insertions(+) diff --git a/tests/protected_type/rule_500_test_input.fixed_lower.vhd b/tests/protected_type/rule_500_test_input.fixed_lower.vhd index 7dabe0d3..723c838a 100644 --- a/tests/protected_type/rule_500_test_input.fixed_lower.vhd +++ b/tests/protected_type/rule_500_test_input.fixed_lower.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected diff --git a/tests/protected_type/rule_500_test_input.fixed_upper.vhd b/tests/protected_type/rule_500_test_input.fixed_upper.vhd index 75d113e3..b60d2aec 100644 --- a/tests/protected_type/rule_500_test_input.fixed_upper.vhd +++ b/tests/protected_type/rule_500_test_input.fixed_upper.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is PROTECTED diff --git a/tests/protected_type/rule_500_test_input.vhd b/tests/protected_type/rule_500_test_input.vhd index e7cf593d..ea735eff 100644 --- a/tests/protected_type/rule_500_test_input.vhd +++ b/tests/protected_type/rule_500_test_input.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected diff --git a/tests/protected_type/rule_501_test_input.fixed_lower.vhd b/tests/protected_type/rule_501_test_input.fixed_lower.vhd index 7dabe0d3..723c838a 100644 --- a/tests/protected_type/rule_501_test_input.fixed_lower.vhd +++ b/tests/protected_type/rule_501_test_input.fixed_lower.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected diff --git a/tests/protected_type/rule_501_test_input.fixed_upper.vhd b/tests/protected_type/rule_501_test_input.fixed_upper.vhd index 216e99e3..2e3f55da 100644 --- a/tests/protected_type/rule_501_test_input.fixed_upper.vhd +++ b/tests/protected_type/rule_501_test_input.fixed_upper.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected diff --git a/tests/protected_type/rule_501_test_input.vhd b/tests/protected_type/rule_501_test_input.vhd index ddb8a02d..910c6406 100644 --- a/tests/protected_type/rule_501_test_input.vhd +++ b/tests/protected_type/rule_501_test_input.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected diff --git a/tests/protected_type/rule_502_test_input.fixed_lower.vhd b/tests/protected_type/rule_502_test_input.fixed_lower.vhd index 7dabe0d3..723c838a 100644 --- a/tests/protected_type/rule_502_test_input.fixed_lower.vhd +++ b/tests/protected_type/rule_502_test_input.fixed_lower.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected diff --git a/tests/protected_type/rule_502_test_input.fixed_upper.vhd b/tests/protected_type/rule_502_test_input.fixed_upper.vhd index e80d6a15..82d08595 100644 --- a/tests/protected_type/rule_502_test_input.fixed_upper.vhd +++ b/tests/protected_type/rule_502_test_input.fixed_upper.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected diff --git a/tests/protected_type/rule_502_test_input.vhd b/tests/protected_type/rule_502_test_input.vhd index 27fe3bea..d7965cbd 100644 --- a/tests/protected_type/rule_502_test_input.vhd +++ b/tests/protected_type/rule_502_test_input.vhd @@ -1,3 +1,4 @@ + package test is type flag_pt is protected From e17a72c7976055badfef8659e3d43b23f602d804 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:55:07 +0100 Subject: [PATCH 07/43] Issue#1285: Updated protected_type tests. --- tests/protected_type/test_rule_500.py | 4 ++-- tests/protected_type/test_rule_501.py | 4 ++-- tests/protected_type/test_rule_502.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/protected_type/test_rule_500.py b/tests/protected_type/test_rule_500.py index a472b0b7..485c75f9 100644 --- a/tests/protected_type/test_rule_500.py +++ b/tests/protected_type/test_rule_500.py @@ -31,7 +31,7 @@ class test_protected_type_rule(unittest.TestCase): self.assertEqual(oRule.name, "protected_type") self.assertEqual(oRule.identifier, "500") - lExpected = [6, 16] + lExpected = [7, 17] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) @@ -43,7 +43,7 @@ class test_protected_type_rule(unittest.TestCase): self.assertEqual(oRule.name, "protected_type") self.assertEqual(oRule.identifier, "500") - lExpected = [3, 13] + lExpected = [4, 14] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) diff --git a/tests/protected_type/test_rule_501.py b/tests/protected_type/test_rule_501.py index 7bff2504..5eeb9d7d 100644 --- a/tests/protected_type/test_rule_501.py +++ b/tests/protected_type/test_rule_501.py @@ -31,7 +31,7 @@ class test_protected_type_rule(unittest.TestCase): self.assertEqual(oRule.name, "protected_type") self.assertEqual(oRule.identifier, "501") - lExpected = [7, 17] + lExpected = [8, 18] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) @@ -43,7 +43,7 @@ class test_protected_type_rule(unittest.TestCase): self.assertEqual(oRule.name, "protected_type") self.assertEqual(oRule.identifier, "501") - lExpected = [4, 14] + lExpected = [5, 15] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) diff --git a/tests/protected_type/test_rule_502.py b/tests/protected_type/test_rule_502.py index b345aeba..2507826d 100644 --- a/tests/protected_type/test_rule_502.py +++ b/tests/protected_type/test_rule_502.py @@ -31,7 +31,7 @@ class test_protected_type_rule(unittest.TestCase): self.assertEqual(oRule.name, "protected_type") self.assertEqual(oRule.identifier, "502") - lExpected = [7, 17] + lExpected = [8, 18] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) @@ -43,7 +43,7 @@ class test_protected_type_rule(unittest.TestCase): self.assertEqual(oRule.name, "protected_type") self.assertEqual(oRule.identifier, "502") - lExpected = [4, 14] + lExpected = [5, 15] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) From f313504306805b482f3c2ea90c9ad4a37cabafa1 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:55:18 +0100 Subject: [PATCH 08/43] Issue#1285: Added tests for protected_type_body rules --- tests/protected_type_body/__init__.py | 0 .../rule_500_test_input.fixed_lower.vhd | 22 ++++++ .../rule_500_test_input.fixed_upper.vhd | 22 ++++++ .../rule_500_test_input.vhd | 22 ++++++ .../rule_501_test_input.fixed_lower.vhd | 22 ++++++ .../rule_501_test_input.fixed_upper.vhd | 22 ++++++ .../rule_501_test_input.vhd | 22 ++++++ .../rule_502_test_input.fixed_lower.vhd | 22 ++++++ .../rule_502_test_input.fixed_upper.vhd | 22 ++++++ .../rule_502_test_input.vhd | 22 ++++++ .../rule_503_test_input.fixed_lower.vhd | 22 ++++++ .../rule_503_test_input.fixed_upper.vhd | 22 ++++++ .../rule_503_test_input.vhd | 22 ++++++ .../rule_504_test_input.fixed_lower.vhd | 22 ++++++ .../rule_504_test_input.fixed_upper.vhd | 22 ++++++ .../rule_504_test_input.vhd | 22 ++++++ tests/protected_type_body/test_rule_500.py | 73 +++++++++++++++++++ tests/protected_type_body/test_rule_501.py | 73 +++++++++++++++++++ tests/protected_type_body/test_rule_502.py | 73 +++++++++++++++++++ tests/protected_type_body/test_rule_503.py | 73 +++++++++++++++++++ tests/protected_type_body/test_rule_504.py | 73 +++++++++++++++++++ 21 files changed, 695 insertions(+) create mode 100644 tests/protected_type_body/__init__.py create mode 100644 tests/protected_type_body/rule_500_test_input.fixed_lower.vhd create mode 100644 tests/protected_type_body/rule_500_test_input.fixed_upper.vhd create mode 100644 tests/protected_type_body/rule_500_test_input.vhd create mode 100644 tests/protected_type_body/rule_501_test_input.fixed_lower.vhd create mode 100644 tests/protected_type_body/rule_501_test_input.fixed_upper.vhd create mode 100644 tests/protected_type_body/rule_501_test_input.vhd create mode 100644 tests/protected_type_body/rule_502_test_input.fixed_lower.vhd create mode 100644 tests/protected_type_body/rule_502_test_input.fixed_upper.vhd create mode 100644 tests/protected_type_body/rule_502_test_input.vhd create mode 100644 tests/protected_type_body/rule_503_test_input.fixed_lower.vhd create mode 100644 tests/protected_type_body/rule_503_test_input.fixed_upper.vhd create mode 100644 tests/protected_type_body/rule_503_test_input.vhd create mode 100644 tests/protected_type_body/rule_504_test_input.fixed_lower.vhd create mode 100644 tests/protected_type_body/rule_504_test_input.fixed_upper.vhd create mode 100644 tests/protected_type_body/rule_504_test_input.vhd create mode 100644 tests/protected_type_body/test_rule_500.py create mode 100644 tests/protected_type_body/test_rule_501.py create mode 100644 tests/protected_type_body/test_rule_502.py create mode 100644 tests/protected_type_body/test_rule_503.py create mode 100644 tests/protected_type_body/test_rule_504.py diff --git a/tests/protected_type_body/__init__.py b/tests/protected_type_body/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/protected_type_body/rule_500_test_input.fixed_lower.vhd b/tests/protected_type_body/rule_500_test_input.fixed_lower.vhd new file mode 100644 index 00000000..324512d1 --- /dev/null +++ b/tests/protected_type_body/rule_500_test_input.fixed_lower.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_500_test_input.fixed_upper.vhd b/tests/protected_type_body/rule_500_test_input.fixed_upper.vhd new file mode 100644 index 00000000..0a5db482 --- /dev/null +++ b/tests/protected_type_body/rule_500_test_input.fixed_upper.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is PROTECTED body + end protected body; + + type flag_pt is PROTECTED body + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is PROTECTED body + end protected body; + + type flag_pt is PROTECTED body + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_500_test_input.vhd b/tests/protected_type_body/rule_500_test_input.vhd new file mode 100644 index 00000000..94407180 --- /dev/null +++ b/tests/protected_type_body/rule_500_test_input.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is PROTECTED body + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is PROTECTED body + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_501_test_input.fixed_lower.vhd b/tests/protected_type_body/rule_501_test_input.fixed_lower.vhd new file mode 100644 index 00000000..324512d1 --- /dev/null +++ b/tests/protected_type_body/rule_501_test_input.fixed_lower.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_501_test_input.fixed_upper.vhd b/tests/protected_type_body/rule_501_test_input.fixed_upper.vhd new file mode 100644 index 00000000..9bdcf930 --- /dev/null +++ b/tests/protected_type_body/rule_501_test_input.fixed_upper.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected BODY + end protected body; + + type flag_pt is protected BODY + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected BODY + end protected body; + + type flag_pt is protected BODY + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_501_test_input.vhd b/tests/protected_type_body/rule_501_test_input.vhd new file mode 100644 index 00000000..87291f1d --- /dev/null +++ b/tests/protected_type_body/rule_501_test_input.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected BODY + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected BODY + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_502_test_input.fixed_lower.vhd b/tests/protected_type_body/rule_502_test_input.fixed_lower.vhd new file mode 100644 index 00000000..324512d1 --- /dev/null +++ b/tests/protected_type_body/rule_502_test_input.fixed_lower.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_502_test_input.fixed_upper.vhd b/tests/protected_type_body/rule_502_test_input.fixed_upper.vhd new file mode 100644 index 00000000..eb49e2ac --- /dev/null +++ b/tests/protected_type_body/rule_502_test_input.fixed_upper.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + END protected body; + + type flag_pt is protected body + END protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + END protected body; + + type flag_pt is protected body + END protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_502_test_input.vhd b/tests/protected_type_body/rule_502_test_input.vhd new file mode 100644 index 00000000..465f62ad --- /dev/null +++ b/tests/protected_type_body/rule_502_test_input.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + END protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + END protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_503_test_input.fixed_lower.vhd b/tests/protected_type_body/rule_503_test_input.fixed_lower.vhd new file mode 100644 index 00000000..324512d1 --- /dev/null +++ b/tests/protected_type_body/rule_503_test_input.fixed_lower.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_503_test_input.fixed_upper.vhd b/tests/protected_type_body/rule_503_test_input.fixed_upper.vhd new file mode 100644 index 00000000..61903cf0 --- /dev/null +++ b/tests/protected_type_body/rule_503_test_input.fixed_upper.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end PROTECTED body; + + type flag_pt is protected body + end PROTECTED body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end PROTECTED body; + + type flag_pt is protected body + end PROTECTED body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_503_test_input.vhd b/tests/protected_type_body/rule_503_test_input.vhd new file mode 100644 index 00000000..e9c06ef8 --- /dev/null +++ b/tests/protected_type_body/rule_503_test_input.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end PROTECTED body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end PROTECTED body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_504_test_input.fixed_lower.vhd b/tests/protected_type_body/rule_504_test_input.fixed_lower.vhd new file mode 100644 index 00000000..324512d1 --- /dev/null +++ b/tests/protected_type_body/rule_504_test_input.fixed_lower.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected body; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_504_test_input.fixed_upper.vhd b/tests/protected_type_body/rule_504_test_input.fixed_upper.vhd new file mode 100644 index 00000000..a8c4d11e --- /dev/null +++ b/tests/protected_type_body/rule_504_test_input.fixed_upper.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected BODY; + + type flag_pt is protected body + end protected BODY; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected BODY; + + type flag_pt is protected body + end protected BODY; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/rule_504_test_input.vhd b/tests/protected_type_body/rule_504_test_input.vhd new file mode 100644 index 00000000..76e66a46 --- /dev/null +++ b/tests/protected_type_body/rule_504_test_input.vhd @@ -0,0 +1,22 @@ + +package body test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected BODY; + +end package body test; + +architecture rtl of test is + + type flag_pt is protected body + end protected body; + + type flag_pt is protected body + end protected BODY; + +begin + +end architecture rtl; diff --git a/tests/protected_type_body/test_rule_500.py b/tests/protected_type_body/test_rule_500.py new file mode 100644 index 00000000..876fded4 --- /dev/null +++ b/tests/protected_type_body/test_rule_500.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_500_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_500_lower(self): + oRule = protected_type_body.rule_500() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "500") + + lExpected = [7, 17] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_500_upper(self): + oRule = protected_type_body.rule_500() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "500") + + lExpected = [4, 14] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_500_lower(self): + oRule = protected_type_body.rule_500() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_500_upper(self): + oRule = protected_type_body.rule_500() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type_body/test_rule_501.py b/tests/protected_type_body/test_rule_501.py new file mode 100644 index 00000000..7a10bb68 --- /dev/null +++ b/tests/protected_type_body/test_rule_501.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_501_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_501_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_501_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_501_lower(self): + oRule = protected_type_body.rule_501() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "501") + + lExpected = [7, 17] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_501_upper(self): + oRule = protected_type_body.rule_501() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "501") + + lExpected = [4, 14] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_501_lower(self): + oRule = protected_type_body.rule_501() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_501_upper(self): + oRule = protected_type_body.rule_501() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type_body/test_rule_502.py b/tests/protected_type_body/test_rule_502.py new file mode 100644 index 00000000..a698d455 --- /dev/null +++ b/tests/protected_type_body/test_rule_502.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_502_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_502_lower(self): + oRule = protected_type_body.rule_502() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "502") + + lExpected = [8, 18] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_502_upper(self): + oRule = protected_type_body.rule_502() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "502") + + lExpected = [5, 15] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_502_lower(self): + oRule = protected_type_body.rule_502() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_502_upper(self): + oRule = protected_type_body.rule_502() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type_body/test_rule_503.py b/tests/protected_type_body/test_rule_503.py new file mode 100644 index 00000000..733c1233 --- /dev/null +++ b/tests/protected_type_body/test_rule_503.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_503_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_503_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_503_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_503_lower(self): + oRule = protected_type_body.rule_503() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "503") + + lExpected = [8, 18] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_503_upper(self): + oRule = protected_type_body.rule_503() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "503") + + lExpected = [5, 15] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_503_lower(self): + oRule = protected_type_body.rule_503() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_503_upper(self): + oRule = protected_type_body.rule_503() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type_body/test_rule_504.py b/tests/protected_type_body/test_rule_504.py new file mode 100644 index 00000000..ddbf9219 --- /dev/null +++ b/tests/protected_type_body/test_rule_504.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_504_test_input.vhd")) + +lExpected_lower = [] +lExpected_lower.append("") +utils.read_file(os.path.join(sTestDir, "rule_504_test_input.fixed_lower.vhd"), lExpected_lower) + +lExpected_upper = [] +lExpected_upper.append("") +utils.read_file(os.path.join(sTestDir, "rule_504_test_input.fixed_upper.vhd"), lExpected_upper) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_504_lower(self): + oRule = protected_type_body.rule_504() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "504") + + lExpected = [8, 18] + + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_rule_504_upper(self): + oRule = protected_type_body.rule_504() + oRule.case = "upper" + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "504") + + lExpected = [5, 15] + oRule.analyze(self.oFile) + self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) + + def test_fix_rule_504_lower(self): + oRule = protected_type_body.rule_504() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_lower, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) + + def test_fix_rule_504_upper(self): + oRule = protected_type_body.rule_504() + oRule.case = "upper" + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected_upper, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) From 157926c19a8d2322e7828d53a987580ddc39b3aa Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Tue, 22 Oct 2024 22:59:02 +0100 Subject: [PATCH 09/43] Issue#1285: Updated documentation for protected_type and protected_type_body rules. --- ...figuring_uppercase_and_lowercase_rules.rst | 10 ++ docs/protected_type_body_rules.rst | 109 ++++++++++++++++++ docs/protected_type_rules.rst | 67 +++++++++++ docs/rule_groups/case_keyword_rule_group.rst | 8 ++ docs/rule_groups/case_rule_group.rst | 8 ++ docs/rules.rst | 2 + 6 files changed, 204 insertions(+) create mode 100644 docs/protected_type_body_rules.rst create mode 100644 docs/protected_type_rules.rst diff --git a/docs/configuring_uppercase_and_lowercase_rules.rst b/docs/configuring_uppercase_and_lowercase_rules.rst index bffd546f..5cc27b2a 100644 --- a/docs/configuring_uppercase_and_lowercase_rules.rst +++ b/docs/configuring_uppercase_and_lowercase_rules.rst @@ -444,6 +444,16 @@ Rules Enforcing Case * `process_017 `_ * `process_019 `_ +* `protected_type_500 `_ +* `protected_type_501 `_ +* `protected_type_502 `_ +* `protected_type_body_500 `_ + +* `protected_type_body_501 `_ +* `protected_type_body_502 `_ +* `protected_type_body_503 `_ +* `protected_type_body_504 `_ + * `range_001 `_ * `range_002 `_ diff --git a/docs/protected_type_body_rules.rst b/docs/protected_type_body_rules.rst new file mode 100644 index 00000000..9e07ed3d --- /dev/null +++ b/docs/protected_type_body_rules.rst @@ -0,0 +1,109 @@ +.. include:: includes.rst + +Protected Type Body Rules +------------------------- + +protected_type_body_500 +####################### + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **protected** keyword in **protected body** has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + type sharedcounter is PROTECTED body + +**Fix** + +.. code-block:: vhdl + + type sharedcounter is protected body + +protected_type_body_501 +####################### + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **body** keyword in **protected body** has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + type sharedcounter is protected BODY + +**Fix** + +.. code-block:: vhdl + + type sharedcounter is protected body + +protected_type_body_502 +####################### + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **end** keyword in **end protected body** has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + END protected body sharedcounter; + +**Fix** + +.. code-block:: vhdl + + end protected body sharedcounter; + +protected_type_body_503 +####################### + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **protected** keyword in **end protected body** has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + end PROTECTED body sharedcounter; + +**Fix** + +.. code-block:: vhdl + + end protected body sharedcounter; + +protected_type_body_504 +####################### + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **body** keyword in **end protected body** has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + end protected BODY sharedcounter; + +**Fix** + +.. code-block:: vhdl + + end protected body sharedcounter; diff --git a/docs/protected_type_rules.rst b/docs/protected_type_rules.rst new file mode 100644 index 00000000..03677848 --- /dev/null +++ b/docs/protected_type_rules.rst @@ -0,0 +1,67 @@ +.. include:: includes.rst + +Protected Type Rules +-------------------- + +protected_type_500 +################## + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **protected** keyword has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + type sharedcounter is PROTECTED + +**Fix** + +.. code-block:: vhdl + + type sharedcounter is protected + +protected_type_501 +################## + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **end** keyword in **end protected** has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + END protected sharedcounter; + +**Fix** + +.. code-block:: vhdl + + end protected sharedcounter; + +protected_type_502 +################## + +|phase_6| |error| |case| |case_keyword| + +This rule checks the **protected** keyword in **end protected** has proper case. + +|configuring_uppercase_and_lowercase_rules_link| + +**Violation** + +.. code-block:: vhdl + + end PROTECTED sharedcounter; + +**Fix** + +.. code-block:: vhdl + + end protected sharedcounter; diff --git a/docs/rule_groups/case_keyword_rule_group.rst b/docs/rule_groups/case_keyword_rule_group.rst index e38f1bee..dfa8135a 100644 --- a/docs/rule_groups/case_keyword_rule_group.rst +++ b/docs/rule_groups/case_keyword_rule_group.rst @@ -136,6 +136,14 @@ Rules Enforcing Case::Keyword Rule Group * `process_008 <../process_rules.html#process-008>`_ * `process_009 <../process_rules.html#process-009>`_ * `process_013 <../process_rules.html#process-013>`_ +* `protected_type_500 <../protected_type_rules.html#protected-type-500>`_ +* `protected_type_501 <../protected_type_rules.html#protected-type-501>`_ +* `protected_type_502 <../protected_type_rules.html#protected-type-502>`_ +* `protected_type_body_500 <../protected_type_rules.html#protected-type-body-500>`_ +* `protected_type_body_501 <../protected_type_rules.html#protected-type-body-501>`_ +* `protected_type_body_502 <../protected_type_rules.html#protected-type-body-502>`_ +* `protected_type_body_503 <../protected_type_rules.html#protected-type-body-503>`_ +* `protected_type_body_504 <../protected_type_rules.html#protected-type-body-504>`_ * `range_001 <../range_rules.html#range-001>`_ * `range_002 <../range_rules.html#range-002>`_ * `record_type_definition_500 <../record_type_definition_rules.html#record-type-definition-500>`_ diff --git a/docs/rule_groups/case_rule_group.rst b/docs/rule_groups/case_rule_group.rst index 1f7ed16f..f604f855 100644 --- a/docs/rule_groups/case_rule_group.rst +++ b/docs/rule_groups/case_rule_group.rst @@ -188,6 +188,14 @@ Rules Enforcing Case Rule Group * `process_013 <../process_rules.html#process-013>`_ * `process_017 <../process_rules.html#process-017>`_ * `process_019 <../process_rules.html#process-019>`_ +* `protected_type_500 <../protected_type_rules.html#protected-type-500>`_ +* `protected_type_501 <../protected_type_rules.html#protected-type-501>`_ +* `protected_type_502 <../protected_type_rules.html#protected-type-502>`_ +* `protected_type_body_500 <../protected_type_rules.html#protected-type-body-500>`_ +* `protected_type_body_501 <../protected_type_rules.html#protected-type-body-501>`_ +* `protected_type_body_502 <../protected_type_rules.html#protected-type-body-502>`_ +* `protected_type_body_503 <../protected_type_rules.html#protected-type-body-503>`_ +* `protected_type_body_504 <../protected_type_rules.html#protected-type-body-504>`_ * `range_001 <../range_rules.html#range-001>`_ * `range_002 <../range_rules.html#range-002>`_ * `record_type_definition_500 <../record_type_definition_rules.html#record-type-definition-500>`_ diff --git a/docs/rules.rst b/docs/rules.rst index 921c2b14..812c4cbe 100644 --- a/docs/rules.rst +++ b/docs/rules.rst @@ -62,6 +62,8 @@ The rules are divided into categories depending on the part of the VHDL code bei procedure_rules.rst procedure_call_rules.rst process_rules.rst + protected_type_rules.rst + protected_type_body_rules.rst range_rules.rst record_type_definition_rules.rst report_statement_rules.rst From 11a4e3e80b5edd5c90681c3b8aa2151920960bcc Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 19:31:53 +0100 Subject: [PATCH 10/43] Issue#1287: Added protected type body as exclusion zone for alignment rules within declarative regions (where relevant). --- vsg/rules/architecture/rule_026.py | 1 + vsg/rules/architecture/rule_029.py | 1 + vsg/rules/block/rule_400.py | 1 + vsg/rules/block/rule_401.py | 1 + vsg/rules/function/rule_012.py | 1 + vsg/rules/function/rule_015.py | 1 + vsg/rules/package_body/rule_400.py | 1 + vsg/rules/package_body/rule_401.py | 1 + vsg/rules/procedure/rule_010.py | 1 + vsg/rules/procedure/rule_401.py | 1 + vsg/rules/process/rule_031.py | 1 + vsg/rules/process/rule_033.py | 1 + 12 files changed, 12 insertions(+) diff --git a/vsg/rules/architecture/rule_026.py b/vsg/rules/architecture/rule_026.py index 69efb730..89acbdbd 100644 --- a/vsg/rules/architecture/rule_026.py +++ b/vsg/rules/architecture/rule_026.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.is_keyword) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_026(Rule): diff --git a/vsg/rules/architecture/rule_029.py b/vsg/rules/architecture/rule_029.py index 936c1148..94048724 100644 --- a/vsg/rules/architecture/rule_029.py +++ b/vsg/rules/architecture/rule_029.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_029(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/block/rule_400.py b/vsg/rules/block/rule_400.py index 319db72c..9486cc69 100644 --- a/vsg/rules/block/rule_400.py +++ b/vsg/rules/block/rule_400.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_400(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/block/rule_401.py b/vsg/rules/block/rule_401.py index d885238d..482f4bda 100644 --- a/vsg/rules/block/rule_401.py +++ b/vsg/rules/block/rule_401.py @@ -13,6 +13,7 @@ lAlign.append(token.alias_declaration.is_keyword) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_401(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/function/rule_012.py b/vsg/rules/function/rule_012.py index 40389054..5a28ebfd 100644 --- a/vsg/rules/function/rule_012.py +++ b/vsg/rules/function/rule_012.py @@ -17,6 +17,7 @@ oEndToken = token.subprogram_body.begin_keyword lUnless = [] lUnless.append([token.procedure_specification.procedure_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_012(Rule): diff --git a/vsg/rules/function/rule_015.py b/vsg/rules/function/rule_015.py index d0af77b2..7eea107b 100644 --- a/vsg/rules/function/rule_015.py +++ b/vsg/rules/function/rule_015.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.procedure_specification.procedure_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_015(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/package_body/rule_400.py b/vsg/rules/package_body/rule_400.py index f17c1b4e..b7493019 100644 --- a/vsg/rules/package_body/rule_400.py +++ b/vsg/rules/package_body/rule_400.py @@ -14,6 +14,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_400(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/package_body/rule_401.py b/vsg/rules/package_body/rule_401.py index e2dfc399..d79f498b 100644 --- a/vsg/rules/package_body/rule_401.py +++ b/vsg/rules/package_body/rule_401.py @@ -18,6 +18,7 @@ oEnd = token.package_body.end_keyword lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_401(Rule): diff --git a/vsg/rules/procedure/rule_010.py b/vsg/rules/procedure/rule_010.py index 6d074359..6573cfda 100644 --- a/vsg/rules/procedure/rule_010.py +++ b/vsg/rules/procedure/rule_010.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.function_specification.function_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_010(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/procedure/rule_401.py b/vsg/rules/procedure/rule_401.py index 4dec4e9c..5038eef3 100644 --- a/vsg/rules/procedure/rule_401.py +++ b/vsg/rules/procedure/rule_401.py @@ -17,6 +17,7 @@ oEndToken = token.subprogram_body.begin_keyword lUnless = [] lUnless.append([token.function_specification.function_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_401(Rule): diff --git a/vsg/rules/process/rule_031.py b/vsg/rules/process/rule_031.py index 21153442..074862d6 100644 --- a/vsg/rules/process/rule_031.py +++ b/vsg/rules/process/rule_031.py @@ -18,6 +18,7 @@ oEnd = token.process_statement.begin_keyword lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_031(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/process/rule_033.py b/vsg/rules/process/rule_033.py index cfad4005..39d43a19 100644 --- a/vsg/rules/process/rule_033.py +++ b/vsg/rules/process/rule_033.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.is_keyword) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_033(Rule): From a00db0f6d82a858b6866cbe4d68869c08d550894 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 19:32:23 +0100 Subject: [PATCH 11/43] Issue#1287: Updated tests for architecture rules --- .../rule_026_test_input.fixed_no_no_no_no.vhd | 11 +++++++++++ .../rule_026_test_input.fixed_yes_no_no_no.vhd | 11 +++++++++++ .../rule_026_test_input.fixed_yes_no_yes_no.vhd | 11 +++++++++++ .../rule_026_test_input.fixed_yes_yes_no_no.vhd | 11 +++++++++++ .../rule_026_test_input.fixed_yes_yes_no_yes.vhd | 11 +++++++++++ tests/architecture/rule_026_test_input.vhd | 11 +++++++++++ tests/architecture/rule_029_test_input.fixed.vhd | 11 +++++++++++ tests/architecture/rule_029_test_input.vhd | 11 +++++++++++ tests/architecture/test_rule_026.py | 12 ++++++------ tests/architecture/test_rule_029.py | 2 +- 10 files changed, 95 insertions(+), 7 deletions(-) diff --git a/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd b/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd index 94e5587f..a18ca132 100644 --- a/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd b/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd index 0842ffcd..afcc6a1f 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd b/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd index 1f84f7f9..ecfb99b1 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd index 88fb869a..c4954f2b 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd index 49e6c8b9..a22b1005 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.vhd b/tests/architecture/rule_026_test_input.vhd index d88c3c0b..6dceee6e 100644 --- a/tests/architecture/rule_026_test_input.vhd +++ b/tests/architecture/rule_026_test_input.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_029_test_input.fixed.vhd b/tests/architecture/rule_029_test_input.fixed.vhd index b1963756..b7decd81 100644 --- a/tests/architecture/rule_029_test_input.fixed.vhd +++ b/tests/architecture/rule_029_test_input.fixed.vhd @@ -59,6 +59,17 @@ architecture RTL of ENTITY1 is signal sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_029_test_input.vhd b/tests/architecture/rule_029_test_input.vhd index cfaacb02..d65fa7d1 100644 --- a/tests/architecture/rule_029_test_input.vhd +++ b/tests/architecture/rule_029_test_input.vhd @@ -59,6 +59,17 @@ architecture RTL of ENTITY1 is signal sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/test_rule_026.py b/tests/architecture/test_rule_026.py index 26afd412..fb992c2a 100644 --- a/tests/architecture/test_rule_026.py +++ b/tests/architecture/test_rule_026.py @@ -27,7 +27,7 @@ class test_rule(unittest.TestCase): self.assertEqual(oRule.name, "architecture") self.assertEqual(oRule.identifier, "026") - lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -42,7 +42,7 @@ class test_rule(unittest.TestCase): self.assertEqual(oRule.name, "architecture") self.assertEqual(oRule.identifier, "026") - lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -75,7 +75,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = "no" oRule.include_type_is_keyword = "no" - lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25] + lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -87,7 +87,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = False oRule.include_type_is_keyword = False - lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25] + lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -210,7 +210,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = "no" oRule.include_type_is_keyword = "yes" - lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25, 34] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -222,7 +222,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = False oRule.include_type_is_keyword = True - lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25, 34] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/architecture/test_rule_029.py b/tests/architecture/test_rule_029.py index 20323ba8..98767f4b 100644 --- a/tests/architecture/test_rule_029.py +++ b/tests/architecture/test_rule_029.py @@ -24,7 +24,7 @@ class test_architecture_rule(unittest.TestCase): def test_rule_029(self): oRule = architecture.rule_029() - lExpected = [6, 8, 9, 10, 11, 23, 25, 26, 28, 29, 48] + lExpected = [6, 8, 9, 10, 11, 23, 25, 26, 28, 29, 48, 69] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 61316475c8c4b197277e7475e179bba6dcf8141f Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 19:35:55 +0100 Subject: [PATCH 12/43] Issue#1287: Updated tests for block rules --- tests/block/rule_400_test_input.fixed.vhd | 11 +++++++++++ tests/block/rule_400_test_input.vhd | 11 +++++++++++ tests/block/rule_401_test_input.fixed.vhd | 11 +++++++++++ tests/block/rule_401_test_input.vhd | 11 +++++++++++ tests/block/test_rule_400.py | 2 +- 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/block/rule_400_test_input.fixed.vhd b/tests/block/rule_400_test_input.fixed.vhd index 55ffda61..b2db68ca 100644 --- a/tests/block/rule_400_test_input.fixed.vhd +++ b/tests/block/rule_400_test_input.fixed.vhd @@ -10,6 +10,17 @@ begin file file1 : std_logic; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/rule_400_test_input.vhd b/tests/block/rule_400_test_input.vhd index a50b16c4..7ee7141d 100644 --- a/tests/block/rule_400_test_input.vhd +++ b/tests/block/rule_400_test_input.vhd @@ -10,6 +10,17 @@ begin file file1 : std_logic; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/rule_401_test_input.fixed.vhd b/tests/block/rule_401_test_input.fixed.vhd index cdb05272..f8df4b67 100644 --- a/tests/block/rule_401_test_input.fixed.vhd +++ b/tests/block/rule_401_test_input.fixed.vhd @@ -11,6 +11,17 @@ begin alias alias1 : subtype_indicator is name; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/rule_401_test_input.vhd b/tests/block/rule_401_test_input.vhd index e30f361d..86ae1b0d 100644 --- a/tests/block/rule_401_test_input.vhd +++ b/tests/block/rule_401_test_input.vhd @@ -11,6 +11,17 @@ begin alias alias1 : subtype_indicator is name; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/test_rule_400.py b/tests/block/test_rule_400.py index a05e4dbf..429bd0e5 100644 --- a/tests/block/test_rule_400.py +++ b/tests/block/test_rule_400.py @@ -27,7 +27,7 @@ class test_block_rule(unittest.TestCase): self.assertEqual(oRule.name, "block") self.assertEqual(oRule.identifier, "400") - lExpected = [8, 10, 11] + lExpected = [8, 10, 11, 20] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From a3b70c9138c9185d797f71ce86cd4a6a66ea7212 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 19:42:20 +0100 Subject: [PATCH 13/43] Issue#1287: Updated tests for function rules --- tests/function/rule_012_test_input.fixed.vhd | 12 ++++++++++++ tests/function/rule_012_test_input.vhd | 12 ++++++++++++ tests/function/rule_015_test_input.fixed.vhd | 12 ++++++++++++ tests/function/rule_015_test_input.vhd | 12 ++++++++++++ tests/function/test_rule_012.py | 2 +- tests/function/test_rule_015.py | 2 +- 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/tests/function/rule_012_test_input.fixed.vhd b/tests/function/rule_012_test_input.fixed.vhd index 74ed7805..ea48164a 100644 --- a/tests/function/rule_012_test_input.fixed.vhd +++ b/tests/function/rule_012_test_input.fixed.vhd @@ -16,6 +16,18 @@ architecture RTL of FIFO is file f : something; alias a : subtype_indicator is name; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/rule_012_test_input.vhd b/tests/function/rule_012_test_input.vhd index e64bfaeb..a7dea1b7 100644 --- a/tests/function/rule_012_test_input.vhd +++ b/tests/function/rule_012_test_input.vhd @@ -16,6 +16,18 @@ architecture RTL of FIFO is file f : something; alias a: subtype_indicator is name; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/rule_015_test_input.fixed.vhd b/tests/function/rule_015_test_input.fixed.vhd index 58b87027..874194d3 100644 --- a/tests/function/rule_015_test_input.fixed.vhd +++ b/tests/function/rule_015_test_input.fixed.vhd @@ -14,6 +14,18 @@ architecture RTL of FIFO is variable v : integer; file f : something; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/rule_015_test_input.vhd b/tests/function/rule_015_test_input.vhd index bd78da82..7fedffcd 100644 --- a/tests/function/rule_015_test_input.vhd +++ b/tests/function/rule_015_test_input.vhd @@ -14,6 +14,18 @@ architecture RTL of FIFO is variable v : integer; file f : something; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/test_rule_012.py b/tests/function/test_rule_012.py index b54dfee1..4a6f020a 100644 --- a/tests/function/test_rule_012.py +++ b/tests/function/test_rule_012.py @@ -28,7 +28,7 @@ class test_function_rule(unittest.TestCase): self.assertEqual(oRule.identifier, "012") self.assertEqual(oRule.groups, ["alignment"]) - lExpected = [14, 16, 17, 18] + lExpected = [14, 16, 17, 18, 21, 26] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/function/test_rule_015.py b/tests/function/test_rule_015.py index b476bcf2..a40f6262 100644 --- a/tests/function/test_rule_015.py +++ b/tests/function/test_rule_015.py @@ -28,7 +28,7 @@ class test_function_rule(unittest.TestCase): self.assertEqual(oRule.identifier, "015") self.assertEqual(oRule.groups, ["alignment"]) - lExpected = [13, 14, 15, 16] + lExpected = [13, 14, 15, 16, 19, 24, 25] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 521c856d3fff10a03004db9e099f4c4ebc32968e Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 19:51:47 +0100 Subject: [PATCH 14/43] Issue#1287: Updated tests for package body rules --- tests/package_body/rule_400_test_input.fixed.vhd | 11 +++++++++++ tests/package_body/rule_400_test_input.vhd | 11 +++++++++++ tests/package_body/rule_401_test_input.fixed.vhd | 11 +++++++++++ tests/package_body/rule_401_test_input.vhd | 11 +++++++++++ tests/package_body/test_rule_400.py | 3 ++- 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tests/package_body/rule_400_test_input.fixed.vhd b/tests/package_body/rule_400_test_input.fixed.vhd index dc0c5975..ecaf12ae 100644 --- a/tests/package_body/rule_400_test_input.fixed.vhd +++ b/tests/package_body/rule_400_test_input.fixed.vhd @@ -55,6 +55,17 @@ package body RTL is constant sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; -- Test functions and procedures defined in architectures diff --git a/tests/package_body/rule_400_test_input.vhd b/tests/package_body/rule_400_test_input.vhd index 6d3af1be..2ad5302c 100644 --- a/tests/package_body/rule_400_test_input.vhd +++ b/tests/package_body/rule_400_test_input.vhd @@ -55,6 +55,17 @@ package body RTL is constant sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; -- Test functions and procedures defined in architectures diff --git a/tests/package_body/rule_401_test_input.fixed.vhd b/tests/package_body/rule_401_test_input.fixed.vhd index f3e32e11..2442f6e2 100644 --- a/tests/package_body/rule_401_test_input.fixed.vhd +++ b/tests/package_body/rule_401_test_input.fixed.vhd @@ -19,4 +19,15 @@ package body RTL is alias a_alias1 is name; alias a_alias2 : subtype_indictor is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; diff --git a/tests/package_body/rule_401_test_input.vhd b/tests/package_body/rule_401_test_input.vhd index cae2d585..fea84a60 100644 --- a/tests/package_body/rule_401_test_input.vhd +++ b/tests/package_body/rule_401_test_input.vhd @@ -19,4 +19,15 @@ package body RTL is alias a_alias1 is name; alias a_alias2 : subtype_indictor is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; diff --git a/tests/package_body/test_rule_400.py b/tests/package_body/test_rule_400.py index 8dd04004..a8f396dc 100644 --- a/tests/package_body/test_rule_400.py +++ b/tests/package_body/test_rule_400.py @@ -32,7 +32,8 @@ class test_package_body_rule(unittest.TestCase): lExpected.extend([21, 22, 23, 25, 26]) lExpected.extend([30, 31]) lExpected.append(44) - lExpected.extend([83, 84, 85]) + lExpected.append(65) + lExpected.extend([94, 95, 96]) oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From f861d9b4e293f0c2a2960afacb1de5e4c2a9a184 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 19:53:28 +0100 Subject: [PATCH 15/43] Issue#1287: Updated tests for procedure rules --- tests/procedure/rule_010_test_input.fixed.vhd | 37 +++++++++++++++++++ tests/procedure/rule_010_test_input.vhd | 37 +++++++++++++++++++ tests/procedure/rule_401_test_input.fixed.vhd | 14 +++++++ tests/procedure/rule_401_test_input.vhd | 14 +++++++ tests/procedure/test_rule_010.py | 2 +- 5 files changed, 103 insertions(+), 1 deletion(-) diff --git a/tests/procedure/rule_010_test_input.fixed.vhd b/tests/procedure/rule_010_test_input.fixed.vhd index 86324c9a..eba00c0d 100644 --- a/tests/procedure/rule_010_test_input.fixed.vhd +++ b/tests/procedure/rule_010_test_input.fixed.vhd @@ -102,6 +102,43 @@ architecture RTL of ENT is begin end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; constant a : in integer; signal b : in std_logic; diff --git a/tests/procedure/rule_010_test_input.vhd b/tests/procedure/rule_010_test_input.vhd index 848d81af..a0cc45f2 100644 --- a/tests/procedure/rule_010_test_input.vhd +++ b/tests/procedure/rule_010_test_input.vhd @@ -102,6 +102,43 @@ architecture RTL of ENT is begin end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; constant a : in integer; signal b : in std_logic; diff --git a/tests/procedure/rule_401_test_input.fixed.vhd b/tests/procedure/rule_401_test_input.fixed.vhd index b4ec9c70..29c6ff0a 100644 --- a/tests/procedure/rule_401_test_input.fixed.vhd +++ b/tests/procedure/rule_401_test_input.fixed.vhd @@ -19,6 +19,20 @@ architecture RTL of FIFO is begin end procedure proc1; + procedure proc1 is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure proc1; + function func1 return integer is constant c : integer; variable v : integer; diff --git a/tests/procedure/rule_401_test_input.vhd b/tests/procedure/rule_401_test_input.vhd index 1d3771b0..491dd022 100644 --- a/tests/procedure/rule_401_test_input.vhd +++ b/tests/procedure/rule_401_test_input.vhd @@ -19,6 +19,20 @@ architecture RTL of FIFO is begin end procedure proc1; + procedure proc1 is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure proc1; + function func1 return integer is constant c : integer; variable v : integer; diff --git a/tests/procedure/test_rule_010.py b/tests/procedure/test_rule_010.py index d8a1cc2e..fc3f0c69 100644 --- a/tests/procedure/test_rule_010.py +++ b/tests/procedure/test_rule_010.py @@ -27,7 +27,7 @@ class test_procedure_rule(unittest.TestCase): self.assertEqual(oRule.name, "procedure") self.assertEqual(oRule.identifier, "010") - lExpected = [31, 32, 34, 99, 100, 132, 133, 149] + lExpected = [31, 32, 34, 99, 100, 117, 169, 170, 186] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From dfc80594254af426664b8dc35cd6e0edf41770f2 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 21:14:52 +0100 Subject: [PATCH 16/43] Issue#1287: Updated tests for process rules --- tests/process/rule_031_test_input.fixed.vhd | 9 +++++++++ tests/process/rule_031_test_input.vhd | 9 +++++++++ tests/process/rule_033_test_input.fixed.vhd | 15 +++++++++++++++ tests/process/rule_033_test_input.vhd | 15 +++++++++++++++ tests/process/test_rule_031.py | 2 +- tests/process/test_rule_033.py | 2 +- 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/tests/process/rule_031_test_input.fixed.vhd b/tests/process/rule_031_test_input.fixed.vhd index 92e8e058..611885de 100644 --- a/tests/process/rule_031_test_input.fixed.vhd +++ b/tests/process/rule_031_test_input.fixed.vhd @@ -119,4 +119,13 @@ begin begin end process PROC; + -- Test protected type body in the process declarative region + PROC : process (a) is + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end process PROC; + end architecture RTL; diff --git a/tests/process/rule_031_test_input.vhd b/tests/process/rule_031_test_input.vhd index f4600ca9..3d15d7c0 100644 --- a/tests/process/rule_031_test_input.vhd +++ b/tests/process/rule_031_test_input.vhd @@ -119,4 +119,13 @@ begin begin end process PROC; + -- Test protected type body in the process declarative region + PROC : process (a) is + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end process PROC; + end architecture RTL; diff --git a/tests/process/rule_033_test_input.fixed.vhd b/tests/process/rule_033_test_input.fixed.vhd index 73ec23d0..41988b09 100644 --- a/tests/process/rule_033_test_input.fixed.vhd +++ b/tests/process/rule_033_test_input.fixed.vhd @@ -46,4 +46,19 @@ begin begin end process; + process + + variable var1 : integer := 0; + file file1 : load_file_file open read_mode is load_file_name; + constant con1 : std_logic := '1'; + alias alias1 is name; + alias alias1 : subtype_indicator is name; + + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + constant constant_1 : integer; + begin end process; + end architecture RTL; diff --git a/tests/process/rule_033_test_input.vhd b/tests/process/rule_033_test_input.vhd index 896d3c02..58d204b7 100644 --- a/tests/process/rule_033_test_input.vhd +++ b/tests/process/rule_033_test_input.vhd @@ -46,4 +46,19 @@ begin begin end process; + process + + variable var1 : integer := 0; + file file1 : load_file_file open read_mode is load_file_name; + constant con1 : std_logic := '1'; + alias alias1 is name; + alias alias1 : subtype_indicator is name; + + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + constant constant_1 : integer; + begin end process; + end architecture RTL; diff --git a/tests/process/test_rule_031.py b/tests/process/test_rule_031.py index 8a9c478c..1fdccc98 100644 --- a/tests/process/test_rule_031.py +++ b/tests/process/test_rule_031.py @@ -27,7 +27,7 @@ class test_process_rule(unittest.TestCase): self.assertEqual(oRule.name, "process") self.assertEqual(oRule.identifier, "031") - lExpected = [11, 12, 13, 14, 32, 34, 35, 37, 38, 65, 88, 103, 104, 118] + lExpected = [11, 12, 13, 14, 32, 34, 35, 37, 38, 65, 88, 103, 104, 118, 125] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/process/test_rule_033.py b/tests/process/test_rule_033.py index 056ee430..14034a8f 100644 --- a/tests/process/test_rule_033.py +++ b/tests/process/test_rule_033.py @@ -27,7 +27,7 @@ class test_process_rule(unittest.TestCase): self.assertEqual(oRule.name, "process") self.assertEqual(oRule.identifier, "033") - lExpected = [22, 23, 24, 25, 26, 41, 42, 43, 44, 45] + lExpected = [22, 23, 24, 25, 26, 41, 42, 43, 44, 45, 57] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 08c1b4049e399b70a9a65f35e963969f5cb49532 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 21:50:46 +0100 Subject: [PATCH 17/43] Issue#1287: Added alignment rules for protected type body --- vsg/rules/protected_type_body/__init__.py | 3 ++ vsg/rules/protected_type_body/rule_400.py | 50 +++++++++++++++++++ vsg/rules/protected_type_body/rule_401.py | 59 +++++++++++++++++++++++ vsg/rules/protected_type_body/rule_402.py | 45 +++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 vsg/rules/protected_type_body/rule_400.py create mode 100644 vsg/rules/protected_type_body/rule_401.py create mode 100644 vsg/rules/protected_type_body/rule_402.py diff --git a/vsg/rules/protected_type_body/__init__.py b/vsg/rules/protected_type_body/__init__.py index 90c0eaba..0d9dfe3f 100644 --- a/vsg/rules/protected_type_body/__init__.py +++ b/vsg/rules/protected_type_body/__init__.py @@ -1,5 +1,8 @@ # -*- coding: utf-8 -*- +from .rule_400 import rule_400 +from .rule_401 import rule_401 +from .rule_402 import rule_402 from .rule_500 import rule_500 from .rule_501 import rule_501 from .rule_502 import rule_502 diff --git a/vsg/rules/protected_type_body/rule_400.py b/vsg/rules/protected_type_body/rule_400.py new file mode 100644 index 00000000..0e551497 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_400.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import align_tokens_in_region_between_tokens_unless_between_tokens as Rule + +lAlign = [] +lAlign.append(token.full_type_declaration.identifier) +lAlign.append(token.incomplete_type_declaration.identifier) +lAlign.append(token.file_declaration.identifier) +lAlign.append(token.constant_declaration.identifier) +lAlign.append(token.subtype_declaration.identifier) +lAlign.append(token.variable_declaration.identifier) +lAlign.append(token.alias_declaration.alias_designator) + +oStart = token.protected_type_body.body_keyword +oEnd = token.protected_type_body.end_body_keyword + +lUnless = [] +lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) + + +class rule_400(Rule): + """ + This rule checks the identifiers for all declarations are aligned in the protected type body declarative region. + + |configuring_identifier_alignment_rules_link| + + **Violation** + + .. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + + **Fix** + + .. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + """ + + def __init__(self): + super().__init__(lAlign, oStart, oEnd, lUnless) + self.solution = "Align identifier." + self.configuration_documentation_link = "configuring_identifier_alignment_rules_link" + self.configuration.remove("separate_generic_port_alignment") + self.configuration.remove("if_control_statements_ends_group") + self.configuration.remove("case_control_statements_ends_group") + self.configuration.remove("loop_control_statements_ends_group") diff --git a/vsg/rules/protected_type_body/rule_401.py b/vsg/rules/protected_type_body/rule_401.py new file mode 100644 index 00000000..8f79f346 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_401.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import align_tokens_in_region_between_tokens_unless_between_tokens as Rule + +lAlign = [] +lAlign.append(token.file_declaration.colon) +lAlign.append(token.signal_declaration.colon) +lAlign.append(token.constant_declaration.colon) +lAlign.append(token.variable_declaration.colon) +lAlign.append(token.alias_declaration.colon) +lAlign.append(token.alias_declaration.is_keyword) + +oStart = token.protected_type_body.body_keyword +oEnd = token.protected_type_body.end_body_keyword + +lUnless = [] +lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) + + +class rule_401(Rule): + """ + This rule checks the colons are in the same column for all declarations in the protected type body declarative part. + + |configuring_keyword_alignment_rules_link| + + **Violation** + + .. code-block:: vhdl + + package my_package is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end package my_package; + + **Fix** + + .. code-block:: vhdl + + package my_package is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end package my_package; + """ + + def __init__(self): + super().__init__(lAlign, oStart, oEnd, lUnless) + self.solution = "Align colon." + self.subphase = 3 + self.configuration.remove("separate_generic_port_alignment") + self.configuration.remove("if_control_statements_ends_group") + self.configuration.remove("case_control_statements_ends_group") + self.configuration.remove("loop_control_statements_ends_group") diff --git a/vsg/rules/protected_type_body/rule_402.py b/vsg/rules/protected_type_body/rule_402.py new file mode 100644 index 00000000..87b5f7e5 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_402.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import align_tokens_in_region_between_tokens_unless_between_tokens as Rule + +lAlign = [] +lAlign.append(token.entity_specification.colon) + +oStart = token.protected_type_body.body_keyword +oEnd = token.protected_type_body.end_body_keyword + +lUnless = [] +lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) + + +class rule_402(Rule): + """ + This rule checks the colons are in the same column for all attribute specifications. + + |configuring_keyword_alignment_rules_link| + + **Violation** + + .. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + **Fix** + + .. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + """ + + def __init__(self): + super().__init__(lAlign, oStart, oEnd, lUnless) + self.solution = "Align colon." + self.configuration.remove("separate_generic_port_alignment") + self.configuration.remove("if_control_statements_ends_group") + self.configuration.remove("case_control_statements_ends_group") + self.configuration.remove("loop_control_statements_ends_group") From 450076c06dff1a37a73b21afbf99111596fb8dc2 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 21:51:02 +0100 Subject: [PATCH 18/43] Issue#1287: Added tests for alignment rules for protected type body --- .../rule_400_test_input.fixed.vhd | 96 +++++++++++++++++++ .../rule_400_test_input.vhd | 96 +++++++++++++++++++ .../rule_401_test_input.fixed.vhd | 30 ++++++ .../rule_401_test_input.vhd | 30 ++++++ .../rule_402_test_input.fixed.vhd | 17 ++++ .../rule_402_test_input.vhd | 17 ++++ tests/protected_type_body/test_rule_400.py | 46 +++++++++ tests/protected_type_body/test_rule_401.py | 46 +++++++++ tests/protected_type_body/test_rule_402.py | 45 +++++++++ 9 files changed, 423 insertions(+) create mode 100644 tests/protected_type_body/rule_400_test_input.fixed.vhd create mode 100644 tests/protected_type_body/rule_400_test_input.vhd create mode 100644 tests/protected_type_body/rule_401_test_input.fixed.vhd create mode 100644 tests/protected_type_body/rule_401_test_input.vhd create mode 100644 tests/protected_type_body/rule_402_test_input.fixed.vhd create mode 100644 tests/protected_type_body/rule_402_test_input.vhd create mode 100644 tests/protected_type_body/test_rule_400.py create mode 100644 tests/protected_type_body/test_rule_401.py create mode 100644 tests/protected_type_body/test_rule_402.py diff --git a/tests/protected_type_body/rule_400_test_input.fixed.vhd b/tests/protected_type_body/rule_400_test_input.fixed.vhd new file mode 100644 index 00000000..73384f03 --- /dev/null +++ b/tests/protected_type_body/rule_400_test_input.fixed.vhd @@ -0,0 +1,96 @@ + +package body RTL is + type t_my_type is protected body + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with different spacing + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with shorter combinations + constant c_sig1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + + -- Test with comments + variable v_var1 : std_logic; + constant c_sig1 : std_logic; + -- some comment + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + -- some comment + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + -- Test multiline declarations + type state_type is ( + state1, state2, + state3, state4 + ); + constant sig1 : std_logic; + + -- This should not error + type state_type2 is ( + state1, state2, + state3, state4 + ); + + constant sig1 : std_logic; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; +end package body RTL; + +-- Test functions and procedures defined in protected body + +package body RTL is + type t_my_type is protected body + procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES ( + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic); + + function func_1 ( + constant a : integer; + signal b : integer; + signal c : unsigned(3 downto 0); + signal d : std_logic_vector(7 downto 0); + constant e : std_logic) return integer; + + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + end protected body; + +end package body RTL; diff --git a/tests/protected_type_body/rule_400_test_input.vhd b/tests/protected_type_body/rule_400_test_input.vhd new file mode 100644 index 00000000..155ec388 --- /dev/null +++ b/tests/protected_type_body/rule_400_test_input.vhd @@ -0,0 +1,96 @@ + +package body RTL is + type t_my_type is protected body + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with different spacing + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with shorter combinations + constant c_sig1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + + -- Test with comments + variable v_var1 : std_logic; + constant c_sig1 : std_logic; + -- some comment + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + -- some comment + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + -- Test multiline declarations + type state_type is ( + state1, state2, + state3, state4 + ); + constant sig1 : std_logic; + + -- This should not error + type state_type2 is ( + state1, state2, + state3, state4 + ); + + constant sig1 : std_logic; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; +end package body RTL; + +-- Test functions and procedures defined in protected body + +package body RTL is + type t_my_type is protected body + procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES ( + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic); + + function func_1 ( + constant a : integer; + signal b : integer; + signal c : unsigned(3 downto 0); + signal d : std_logic_vector(7 downto 0); + constant e : std_logic) return integer; + + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + end protected body; + +end package body RTL; diff --git a/tests/protected_type_body/rule_401_test_input.fixed.vhd b/tests/protected_type_body/rule_401_test_input.fixed.vhd new file mode 100644 index 00000000..2f05bd39 --- /dev/null +++ b/tests/protected_type_body/rule_401_test_input.fixed.vhd @@ -0,0 +1,30 @@ + +package body RTL is + type t_my_type is protected body + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; + +end package body RTL; diff --git a/tests/protected_type_body/rule_401_test_input.vhd b/tests/protected_type_body/rule_401_test_input.vhd new file mode 100644 index 00000000..5604f06e --- /dev/null +++ b/tests/protected_type_body/rule_401_test_input.vhd @@ -0,0 +1,30 @@ + +package body RTL is + type t_my_type is protected body + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; + +end package body RTL; diff --git a/tests/protected_type_body/rule_402_test_input.fixed.vhd b/tests/protected_type_body/rule_402_test_input.fixed.vhd new file mode 100644 index 00000000..00026366 --- /dev/null +++ b/tests/protected_type_body/rule_402_test_input.fixed.vhd @@ -0,0 +1,17 @@ + +package body RTL is + type t_my_type is protected body + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + procedure rst_procedure is + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + begin + end procedure; + end protected body; +end package body RTL; diff --git a/tests/protected_type_body/rule_402_test_input.vhd b/tests/protected_type_body/rule_402_test_input.vhd new file mode 100644 index 00000000..f9468f7e --- /dev/null +++ b/tests/protected_type_body/rule_402_test_input.vhd @@ -0,0 +1,17 @@ + +package body RTL is + type t_my_type is protected body + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + procedure rst_procedure is + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + begin + end procedure; + end protected body; +end package body RTL; diff --git a/tests/protected_type_body/test_rule_400.py b/tests/protected_type_body/test_rule_400.py new file mode 100644 index 00000000..590a786e --- /dev/null +++ b/tests/protected_type_body/test_rule_400.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_400_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_400_test_input.fixed.vhd"), lExpected) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_400(self): + oRule = protected_type_body.rule_400() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "400") + + lExpected = [] + lExpected.extend([7, 8, 9, 10, 21, 22, 23, 25, 26, 30, 31, 44, 90, 91, 92]) + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_400(self): + oRule = protected_type_body.rule_400() + + 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/protected_type_body/test_rule_401.py b/tests/protected_type_body/test_rule_401.py new file mode 100644 index 00000000..b7204c9e --- /dev/null +++ b/tests/protected_type_body/test_rule_401.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_401_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_401_test_input.fixed.vhd"), lExpected) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_401(self): + oRule = protected_type_body.rule_401() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "401") + + lExpected = [] + lExpected.extend([14, 15, 16, 19, 20]) + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_401(self): + oRule = protected_type_body.rule_401() + + 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/protected_type_body/test_rule_402.py b/tests/protected_type_body/test_rule_402.py new file mode 100644 index 00000000..b2a93dcc --- /dev/null +++ b/tests/protected_type_body/test_rule_402.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_402_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_402_test_input.fixed.vhd"), lExpected) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_402(self): + oRule = protected_type_body.rule_402() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "402") + + lExpected = [4, 6] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_402(self): + oRule = protected_type_body.rule_402() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) From 28d32324810a066fd45243fe9310e3e6f64b5481 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 21:52:23 +0100 Subject: [PATCH 19/43] Issue#1287: Updated style test --- .../styles/jcl/rule_400_test_input.fixed.vhd | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/styles/jcl/rule_400_test_input.fixed.vhd b/tests/styles/jcl/rule_400_test_input.fixed.vhd index 2c77b731..ce892868 100644 --- a/tests/styles/jcl/rule_400_test_input.fixed.vhd +++ b/tests/styles/jcl/rule_400_test_input.fixed.vhd @@ -47,14 +47,14 @@ package body pkg_bdy is end package body pkg_bdy; entity ENT is - signal sig1 : std_logic := '0'; -- Signal Comment - constant default_value : integer := 32; -- Constant Comment - shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment + signal sig1 : std_logic := '0'; -- Signal Comment + constant default_value : integer := 32; -- Constant Comment + shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment procedure proc1 is - constant c : std_logic := '0'; -- Constant Comment - variable v : integer := 32; -- Variable Comment + constant c : std_logic := '0'; -- Constant Comment + variable v : integer := 32; -- Variable Comment begin @@ -62,17 +62,17 @@ entity ENT is function func1 return integer is - constant c : integer := 32; -- Constant Comment - variable v : std_logic := '1'; -- Variable Comment + constant c : integer := 32; -- Constant Comment + variable v : std_logic := '1'; -- Variable Comment begin end function func1; - type t_flag_type is protected body -- protected type declaration + type t_flag_type is protected body -- protected type declaration - constant default_value : integer := 32; -- Constant Comment - shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment + constant default_value : integer := 32; -- Constant Comment + shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment end protected body T_FLAG_TYPE; @@ -80,9 +80,9 @@ end entity ENT; architecture RTL of FIFO is - signal sig1 : std_logic := '0'; -- Signal Comment - constant default_value : integer := 32; -- Constant Comment - shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment + signal sig1 : std_logic := '0'; -- Signal Comment + constant default_value : integer := 32; -- Constant Comment + shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment procedure proc1 is From 5ca74da98e9aedfb086c1fe84df59462a25f3a38 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 21:57:39 +0100 Subject: [PATCH 20/43] Issue#1287: Added documentation for alignment rules for protected type body --- ...configuring_identifier_alignment_rules.rst | 1 + docs/configuring_keyword_alignment_rules.rst | 2 + docs/protected_type_body_rules.rst | 81 +++++++++++++++++++ docs/rule_groups/alignment_rule_group.rst | 3 + vsg/rules/protected_type_body/rule_401.py | 8 +- 5 files changed, 91 insertions(+), 4 deletions(-) diff --git a/docs/configuring_identifier_alignment_rules.rst b/docs/configuring_identifier_alignment_rules.rst index 5e433548..cb521044 100644 --- a/docs/configuring_identifier_alignment_rules.rst +++ b/docs/configuring_identifier_alignment_rules.rst @@ -148,3 +148,4 @@ Rules Enforcing Identifier Alignment * `package_019 `_ * `package_body_400 `_ * `procedure_010 `_ +* `protected_type_body_400 `_ diff --git a/docs/configuring_keyword_alignment_rules.rst b/docs/configuring_keyword_alignment_rules.rst index 4c17032b..d99940d8 100644 --- a/docs/configuring_keyword_alignment_rules.rst +++ b/docs/configuring_keyword_alignment_rules.rst @@ -986,6 +986,8 @@ Rules Enforcing Keyword Alignment * `process_035 `_ * `process_400 `_ * `process_401 `_ +* `protected_type_body_401 `_ +* `protected_type_body_402 `_ * `sequential_400 `_ * `subprogram_body_400 `_ * `subprogram_body_401 `_ diff --git a/docs/protected_type_body_rules.rst b/docs/protected_type_body_rules.rst index 9e07ed3d..bd98cee9 100644 --- a/docs/protected_type_body_rules.rst +++ b/docs/protected_type_body_rules.rst @@ -3,6 +3,87 @@ Protected Type Body Rules ------------------------- +protected_type_body_400 +####################### + +|phase_5| |error| |alignment| + +This rule checks the identifiers for all declarations are aligned in the protected type body declarative region. + +|configuring_identifier_alignment_rules_link| + +**Violation** + +.. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + +**Fix** + +.. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + +protected_type_body_401 +####################### + +|phase_5| |error| |alignment| + +This rule checks the colons are in the same column for all declarations in the protected type body declarative part. + +|configuring_keyword_alignment_rules_link| + +**Violation** + +.. code-block:: vhdl + + type my_type protected body is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end protected body; + +**Fix** + +.. code-block:: vhdl + + type my_type protected body is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end protected body; + +protected_type_body_402 +####################### + +|phase_5| |error| |alignment| + +This rule checks the colons are in the same column for all attribute specifications. + +|configuring_keyword_alignment_rules_link| + +**Violation** + +.. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + +**Fix** + +.. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + protected_type_body_500 ####################### diff --git a/docs/rule_groups/alignment_rule_group.rst b/docs/rule_groups/alignment_rule_group.rst index b493cddf..67723a43 100644 --- a/docs/rule_groups/alignment_rule_group.rst +++ b/docs/rule_groups/alignment_rule_group.rst @@ -64,6 +64,9 @@ Rules Enforcing Alignment Rule Group * `process_035 <../process_rules.html#process-035>`_ * `process_400 <../process_rules.html#process-400>`_ * `process_401 <../process_rules.html#process-401>`_ +* `protected_type_body_400 <../protected_type_body_rules.html#protected-type-body-400>`_ +* `protected_type_body_401 <../protected_type_body_rules.html#protected-type-body-401>`_ +* `protected_type_body_402 <../protected_type_body_rules.html#protected-type-body-402>`_ * `report_statement_400 <../report_statement_rules.html#report-statement-400>`_ * `selected_assignment_400 <../selected_assignment_rules.html#selected-assignment-400>`_ * `sequential_004 <../sequential_rules.html#sequential-004>`_ diff --git a/vsg/rules/protected_type_body/rule_401.py b/vsg/rules/protected_type_body/rule_401.py index 8f79f346..04b759ef 100644 --- a/vsg/rules/protected_type_body/rule_401.py +++ b/vsg/rules/protected_type_body/rule_401.py @@ -28,25 +28,25 @@ class rule_401(Rule): .. code-block:: vhdl - package my_package is + type my_type protected body is signal wr_en : std_logic; signal rd_en : std_logic; constant c_period : time; - end package my_package; + end protected body; **Fix** .. code-block:: vhdl - package my_package is + type my_type protected body is signal wr_en : std_logic; signal rd_en : std_logic; constant c_period : time; - end package my_package; + end protected body; """ def __init__(self): From e40969ca7cb49ebb62f2e15333ee04f550bec4a0 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 24 Oct 2024 22:05:33 +0100 Subject: [PATCH 21/43] Issue#1287: Style --- vsg/rules/protected_type_body/rule_400.py | 4 +++- vsg/rules/protected_type_body/rule_401.py | 4 +++- vsg/rules/protected_type_body/rule_402.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/vsg/rules/protected_type_body/rule_400.py b/vsg/rules/protected_type_body/rule_400.py index 0e551497..bb084440 100644 --- a/vsg/rules/protected_type_body/rule_400.py +++ b/vsg/rules/protected_type_body/rule_400.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules import align_tokens_in_region_between_tokens_unless_between_tokens as Rule +from vsg.rules import ( + align_tokens_in_region_between_tokens_unless_between_tokens as Rule, +) lAlign = [] lAlign.append(token.full_type_declaration.identifier) diff --git a/vsg/rules/protected_type_body/rule_401.py b/vsg/rules/protected_type_body/rule_401.py index 04b759ef..aef07eb2 100644 --- a/vsg/rules/protected_type_body/rule_401.py +++ b/vsg/rules/protected_type_body/rule_401.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules import align_tokens_in_region_between_tokens_unless_between_tokens as Rule +from vsg.rules import ( + align_tokens_in_region_between_tokens_unless_between_tokens as Rule, +) lAlign = [] lAlign.append(token.file_declaration.colon) diff --git a/vsg/rules/protected_type_body/rule_402.py b/vsg/rules/protected_type_body/rule_402.py index 87b5f7e5..839700c1 100644 --- a/vsg/rules/protected_type_body/rule_402.py +++ b/vsg/rules/protected_type_body/rule_402.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules import align_tokens_in_region_between_tokens_unless_between_tokens as Rule +from vsg.rules import ( + align_tokens_in_region_between_tokens_unless_between_tokens as Rule, +) lAlign = [] lAlign.append(token.entity_specification.colon) From 8d27c944397bf43f1e9fbf3357a42f63128113fd Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:22:44 +0000 Subject: [PATCH 22/43] Issue#1319: Update generic_map_001 to work on all instances of `generic map` --- vsg/rules/generic_map/rule_001.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vsg/rules/generic_map/rule_001.py b/vsg/rules/generic_map/rule_001.py index 78fd247b..ec30923c 100644 --- a/vsg/rules/generic_map/rule_001.py +++ b/vsg/rules/generic_map/rule_001.py @@ -1,17 +1,14 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules import token_case_in_range_bounded_by_tokens +from vsg.rules import token_case lTokens = [] lTokens.append(token.generic_map_aspect.generic_keyword) lTokens.append(token.generic_map_aspect.map_keyword) -oStart = token.component_instantiation_statement.label_colon -oEnd = token.component_instantiation_statement.semicolon - -class rule_001(token_case_in_range_bounded_by_tokens): +class rule_001(token_case): """ This rule checks the **generic map** keywords have proper case. @@ -31,5 +28,5 @@ class rule_001(token_case_in_range_bounded_by_tokens): """ def __init__(self): - super().__init__(lTokens, oStart, oEnd) + super().__init__(lTokens) self.groups.append("case::keyword") From c683aff494444d355dc7510a6473fccd63d48bc5 Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:24:13 +0000 Subject: [PATCH 23/43] Issue#1319: Update generic_map_001 test to test all instances of generic map. --- tests/generic_map/rule_001_test_input.vhd | 82 ++++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/tests/generic_map/rule_001_test_input.vhd b/tests/generic_map/rule_001_test_input.vhd index 0f14ffcf..0e7d2e58 100644 --- a/tests/generic_map/rule_001_test_input.vhd +++ b/tests/generic_map/rule_001_test_input.vhd @@ -1,6 +1,26 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC map ( + g_test => c_test + ); + + function my_func is new my_func + generic MAP ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +35,6 @@ begin PORT_3 => w_port_3 ); - -- Violations below - U_INST1 : INST1 GENERIC MAP ( G_GEN_1 => 1, @@ -38,4 +56,64 @@ begin G_GEN_3 => 3 ); + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic MAP ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic MAP ( + g_test => c_test + ); From b7ec85062e5bb7349a1e965e4164be1319b01fa3 Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:25:36 +0000 Subject: [PATCH 24/43] Issue#1319: Update generic_map_001 test to test all instances of generic map. --- .../rule_001_test_input.fixed_upper.vhd | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/tests/generic_map/rule_001_test_input.fixed_upper.vhd b/tests/generic_map/rule_001_test_input.fixed_upper.vhd index 8fcb9932..14fe08d4 100644 --- a/tests/generic_map/rule_001_test_input.fixed_upper.vhd +++ b/tests/generic_map/rule_001_test_input.fixed_upper.vhd @@ -1,6 +1,26 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +35,6 @@ begin PORT_3 => w_port_3 ); - -- Violations below - U_INST1 : INST1 GENERIC MAP ( G_GEN_1 => 1, @@ -38,4 +56,64 @@ begin G_GEN_3 => 3 ); + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); From aa63662ecd3219671b4279f19872f0e9387f9919 Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:25:58 +0000 Subject: [PATCH 25/43] Issue#1319: Update generic_map_001 test to test all instances of generic map. --- .../rule_001_test_input.fixed_lower.vhd | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/tests/generic_map/rule_001_test_input.fixed_lower.vhd b/tests/generic_map/rule_001_test_input.fixed_lower.vhd index f57d8a36..d5286c8a 100644 --- a/tests/generic_map/rule_001_test_input.fixed_lower.vhd +++ b/tests/generic_map/rule_001_test_input.fixed_lower.vhd @@ -1,6 +1,26 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +35,6 @@ begin PORT_3 => w_port_3 ); - -- Violations below - U_INST1 : INST1 generic map ( G_GEN_1 => 1, @@ -38,4 +56,64 @@ begin G_GEN_3 => 3 ); + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); From 784913ce4af0bf414b4cb14ef3c34039b49ea274 Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:30:09 +0000 Subject: [PATCH 26/43] Issue#1319: Update generic_map_001 test to test all instances of generic map. --- tests/generic_map/test_rule_001.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/generic_map/test_rule_001.py b/tests/generic_map/test_rule_001.py index 7787b26a..278911ff 100644 --- a/tests/generic_map/test_rule_001.py +++ b/tests/generic_map/test_rule_001.py @@ -31,7 +31,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "001") - lExpected = [21, 21, 28, 35] + lExpected = [10, 10, 15, 20, 39, 39, 46, 53, 73, 73, 83, 93, 107, 107, 112, 117] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) @@ -43,7 +43,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "001") - lExpected = [7, 7, 28, 35] + lExpected = [5, 5, 15, 20, 27, 27, 46, 53, 63, 63, 83, 93, 102, 102, 112, 117] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) From 9745609d32370b80fb7d8d91f1f2363adf9bad5f Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:40:16 +0000 Subject: [PATCH 27/43] Issue#1319: Updated generic_map_002 to work on all instances of generic maps. --- vsg/rules/generic_map/rule_002.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vsg/rules/generic_map/rule_002.py b/vsg/rules/generic_map/rule_002.py index 5d397c5b..62920005 100644 --- a/vsg/rules/generic_map/rule_002.py +++ b/vsg/rules/generic_map/rule_002.py @@ -5,8 +5,8 @@ from vsg.rules import ( token_case_formal_part_of_association_element_in_map_between_tokens, ) -oStart = token.component_instantiation_statement.instantiation_label -oEnd = token.component_instantiation_statement.semicolon +oStart = token.generic_map_aspect.generic_keyword +oEnd = token.generic_map_aspect.close_parenthesis sMapType = "generic" From 0d2c1c494593bf387a3648a7a47fe23ba58eb241 Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:41:38 +0000 Subject: [PATCH 28/43] Issue#1319: Updated tests for generic_map_002 Test are now exercising all instances of generic maps. --- .../rule_002_test_input.fixed_lower.vhd | 97 ++++++++++++++++--- .../rule_002_test_input.fixed_upper.vhd | 97 ++++++++++++++++--- tests/generic_map/rule_002_test_input.vhd | 97 ++++++++++++++++--- tests/generic_map/test_rule_002.py | 4 +- 4 files changed, 245 insertions(+), 50 deletions(-) diff --git a/tests/generic_map/rule_002_test_input.fixed_lower.vhd b/tests/generic_map/rule_002_test_input.fixed_lower.vhd index 499d0010..cc1392b2 100644 --- a/tests/generic_map/rule_002_test_input.fixed_lower.vhd +++ b/tests/generic_map/rule_002_test_input.fixed_lower.vhd @@ -1,22 +1,23 @@ -architecture ARCH of ENTITY1 is +package my_pkg_g is new my_pkg + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + +architecture rtl of test is + +function my_func is new my_func + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); begin - U_INST1 : INST1 - generic map ( - g_gen_1(3 downto 0) => 3, - g_gen_2(2 downto 1) => 4, - g_gen_3 => 5 - ) - port map ( - PORT_1(3 downto 0) => w_port_1, - PORT_2 => w_port_2, - PORT_3(2 downto 1) => w_port_3 - ); - - -- Violations below - U_INST1 : INST1 + u_inst1 : inst1 generic map ( g_gen_1(3 downto 0) => 3, g_gen_2(2 downto 1) => 4, @@ -28,4 +29,68 @@ begin port_3(2 downto 1) => w_port_3 ); -end architecture ARCH; + my_block : block is + + generic ( + g_test : boolean + ); + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + + begin + + end block my_block; + +end architecture rtl; + + -- Violations below + +PACKAGE MY_PKG_G IS NEW MY_PKG + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ); + +ARCHITECTURE RTL OF TEST IS + +FUNCTION MY_FUNC IS NEW MY_FUNC + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ); + +BEGIN + + U_INST1 : INST1 + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ) + PORT MAP ( + PORT_1(3 DOWNTO 0) => W_PORT_1, + PORT_2 => W_PORT_2, + PORT_3(2 DOWNTO 1) => W_PORT_3 + ); + + MY_BLOCK : BLOCK IS + + GENERIC ( + G_TEST : BOOLEAN + ); + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ); + + BEGIN + + END BLOCK MY_BLOCK; + +END ARCHITECTURE RTL; diff --git a/tests/generic_map/rule_002_test_input.fixed_upper.vhd b/tests/generic_map/rule_002_test_input.fixed_upper.vhd index 46c2fc07..14184d08 100644 --- a/tests/generic_map/rule_002_test_input.fixed_upper.vhd +++ b/tests/generic_map/rule_002_test_input.fixed_upper.vhd @@ -1,22 +1,23 @@ -architecture ARCH of ENTITY1 is +package my_pkg_g is new my_pkg + generic map ( + G_GEN_1(3 downto 0) => 3, + G_GEN_2(2 downto 1) => 4, + G_GEN_3 => 5 + ); + +architecture rtl of test is + +function my_func is new my_func + generic map ( + G_GEN_1(3 downto 0) => 3, + G_GEN_2(2 downto 1) => 4, + G_GEN_3 => 5 + ); begin - U_INST1 : INST1 - generic map ( - G_GEN_1(3 downto 0) => 3, - G_GEN_2(2 downto 1) => 4, - G_GEN_3 => 5 - ) - port map ( - PORT_1(3 downto 0) => w_port_1, - PORT_2 => w_port_2, - PORT_3(2 downto 1) => w_port_3 - ); - - -- Violations below - U_INST1 : INST1 + u_inst1 : inst1 generic map ( G_GEN_1(3 downto 0) => 3, G_GEN_2(2 downto 1) => 4, @@ -28,4 +29,68 @@ begin port_3(2 downto 1) => w_port_3 ); -end architecture ARCH; + my_block : block is + + generic ( + g_test : boolean + ); + generic map ( + G_GEN_1(3 downto 0) => 3, + G_GEN_2(2 downto 1) => 4, + G_GEN_3 => 5 + ); + + begin + + end block my_block; + +end architecture rtl; + + -- Violations below + +PACKAGE MY_PKG_G IS NEW MY_PKG + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +ARCHITECTURE RTL OF TEST IS + +FUNCTION MY_FUNC IS NEW MY_FUNC + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +BEGIN + + U_INST1 : INST1 + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ) + PORT MAP ( + PORT_1(3 DOWNTO 0) => W_PORT_1, + PORT_2 => W_PORT_2, + PORT_3(2 DOWNTO 1) => W_PORT_3 + ); + + MY_BLOCK : BLOCK IS + + GENERIC ( + G_TEST : BOOLEAN + ); + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + + BEGIN + + END BLOCK MY_BLOCK; + +END ARCHITECTURE RTL; diff --git a/tests/generic_map/rule_002_test_input.vhd b/tests/generic_map/rule_002_test_input.vhd index 03583d52..09af694f 100644 --- a/tests/generic_map/rule_002_test_input.vhd +++ b/tests/generic_map/rule_002_test_input.vhd @@ -1,22 +1,23 @@ -architecture ARCH of ENTITY1 is +package my_pkg_g is new my_pkg + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + +architecture rtl of test is + +function my_func is new my_func + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); begin - U_INST1 : INST1 - generic map ( - G_GEN_1(3 downto 0) => 3, - G_GEN_2(2 downto 1) => 4, - G_GEN_3 => 5 - ) - port map ( - PORT_1(3 downto 0) => w_port_1, - PORT_2 => w_port_2, - PORT_3(2 downto 1) => w_port_3 - ); - - -- Violations below - U_INST1 : INST1 + u_inst1 : inst1 generic map ( g_gen_1(3 downto 0) => 3, g_gen_2(2 downto 1) => 4, @@ -28,4 +29,68 @@ begin port_3(2 downto 1) => w_port_3 ); -end architecture ARCH; + my_block : block is + + generic ( + g_test : boolean + ); + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + + begin + + end block my_block; + +end architecture rtl; + + -- Violations below + +PACKAGE MY_PKG_G IS NEW MY_PKG + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +ARCHITECTURE RTL OF TEST IS + +FUNCTION MY_FUNC IS NEW MY_FUNC + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +BEGIN + + U_INST1 : INST1 + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ) + PORT MAP ( + PORT_1(3 DOWNTO 0) => W_PORT_1, + PORT_2 => W_PORT_2, + PORT_3(2 DOWNTO 1) => W_PORT_3 + ); + + MY_BLOCK : BLOCK IS + + GENERIC ( + G_TEST : BOOLEAN + ); + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + + BEGIN + + END BLOCK MY_BLOCK; + +END ARCHITECTURE RTL; diff --git a/tests/generic_map/test_rule_002.py b/tests/generic_map/test_rule_002.py index 44a8a748..304642ab 100644 --- a/tests/generic_map/test_rule_002.py +++ b/tests/generic_map/test_rule_002.py @@ -31,7 +31,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "002") - lExpected = [8, 9, 10] + lExpected = [53, 54, 55, 62, 63, 64, 71 ,72, 73, 87, 88, 89] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) @@ -43,7 +43,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "002") - lExpected = [21, 22, 23] + lExpected = [4, 5, 6, 13, 14, 15, 22, 23, 24, 38, 39, 40] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) From fed929521a43e956b8add1c627eed8ddcfdd7c24 Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 14 Nov 2024 14:52:46 +0000 Subject: [PATCH 29/43] Issue#1319: Formatting correction. --- tests/generic_map/test_rule_002.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generic_map/test_rule_002.py b/tests/generic_map/test_rule_002.py index 304642ab..ebee76db 100644 --- a/tests/generic_map/test_rule_002.py +++ b/tests/generic_map/test_rule_002.py @@ -31,7 +31,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "002") - lExpected = [53, 54, 55, 62, 63, 64, 71 ,72, 73, 87, 88, 89] + lExpected = [53, 54, 55, 62, 63, 64, 71, 72, 73, 87, 88, 89] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) From cca23e5a9b58d5d92ebadcfd21de199aa67895de Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 13:42:04 +0000 Subject: [PATCH 30/43] Issue#1319: Updated test for rule generic_map_003 to test generic maps other than those in component instantiations. --- .../generic_map/rule_003_test_input.fixed.vhd | 79 ++++++++++++++++++- tests/generic_map/rule_003_test_input.vhd | 79 ++++++++++++++++++- tests/generic_map/test_rule_003.py | 3 +- 3 files changed, 158 insertions(+), 3 deletions(-) diff --git a/tests/generic_map/rule_003_test_input.fixed.vhd b/tests/generic_map/rule_003_test_input.fixed.vhd index 29e96751..55222a62 100644 --- a/tests/generic_map/rule_003_test_input.fixed.vhd +++ b/tests/generic_map/rule_003_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,6 +20,32 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map( G_GEN_1 => 3, @@ -27,8 +58,35 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( @@ -36,10 +94,29 @@ begin G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map + ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + + g_test => c_test + ); + diff --git a/tests/generic_map/rule_003_test_input.vhd b/tests/generic_map/rule_003_test_input.vhd index 837bd592..743399f7 100644 --- a/tests/generic_map/rule_003_test_input.vhd +++ b/tests/generic_map/rule_003_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,6 +20,32 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map( G_GEN_1 => 3, @@ -27,8 +58,35 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map + ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( @@ -36,10 +94,29 @@ begin G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map + ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map + ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map + ( + g_test => c_test + ); + diff --git a/tests/generic_map/test_rule_003.py b/tests/generic_map/test_rule_003.py index 1d348017..97fe9cb5 100644 --- a/tests/generic_map/test_rule_003.py +++ b/tests/generic_map/test_rule_003.py @@ -20,6 +20,7 @@ class test_generic_map_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) + self.maxDiff = None def test_rule_003(self): oRule = generic_map.rule_003() @@ -27,7 +28,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "003") - lExpected = [33] + lExpected = [83, 91, 108, 118] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 3b3c1a037214ed9c36224475651c51f65ec0ae4b Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 13:51:04 +0000 Subject: [PATCH 31/43] Issue#1319: Updated test for rule generic_map_004 to test generic maps other than those in component instantiations. --- .../generic_map/rule_004_test_input.fixed.vhd | 84 +++++++++++++++++- tests/generic_map/rule_004_test_input.vhd | 88 +++++++++++++++++-- tests/generic_map/test_rule_004.py | 3 +- 3 files changed, 163 insertions(+), 12 deletions(-) diff --git a/tests/generic_map/rule_004_test_input.fixed.vhd b/tests/generic_map/rule_004_test_input.fixed.vhd index eac8fc07..bb72dafd 100644 --- a/tests/generic_map/rule_004_test_input.fixed.vhd +++ b/tests/generic_map/rule_004_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test +); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, @@ -27,13 +58,58 @@ begin PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); +); + + my_block : block is + generic ( + g_test : BOOLEAN +); + generic map ( + g_test => C_TEST +); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test +); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test +); + +begin U_INST1 : INST1 generic map ( - G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3 + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 +) + port map + ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3); + + my_block : block is + generic ( + g_test : BOOLEAN); + generic map ( + g_test => C_TEST ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test +); diff --git a/tests/generic_map/rule_004_test_input.vhd b/tests/generic_map/rule_004_test_input.vhd index e22d7991..e577164c 100644 --- a/tests/generic_map/rule_004_test_input.vhd +++ b/tests/generic_map/rule_004_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,23 +20,92 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test +); + +begin + + U_INST1 : INST1 + generic map ( + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 +) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 +); + + my_block : block is + generic ( + g_test : BOOLEAN +); + generic map ( + g_test => C_TEST +); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test +); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, G_GEN_2 => 4, G_GEN_3 => 5) - port map ( + port map + ( PORT_1 => w_port_1, PORT_2 => w_port_2, - PORT_3 => w_port_3 - ); + PORT_3 => w_port_3); - U_INST1 : INST1 + my_block : block is + generic ( + g_test : BOOLEAN); generic map ( - G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3); + g_test => C_TEST); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test); diff --git a/tests/generic_map/test_rule_004.py b/tests/generic_map/test_rule_004.py index c6424775..7ed41572 100644 --- a/tests/generic_map/test_rule_004.py +++ b/tests/generic_map/test_rule_004.py @@ -20,6 +20,7 @@ class test_generic_map_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) + self.maxDiff = None def test_rule_004(self): oRule = generic_map.rule_004() @@ -27,7 +28,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "004") - lExpected = [24, 35] + lExpected = [84, 92, 103, 111] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 97c5317256bc81c123bc7d6040c97107276e73e1 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 13:58:32 +0000 Subject: [PATCH 32/43] Issue#1319: Updated test for rule generic_map_005 to test generic maps other than those in component instantiations. --- .../generic_map/rule_005_test_input.fixed.vhd | 87 +++++++++++++++++-- tests/generic_map/rule_005_test_input.vhd | 79 ++++++++++++++++- tests/generic_map/test_rule_005.py | 2 +- 3 files changed, 158 insertions(+), 10 deletions(-) diff --git a/tests/generic_map/rule_005_test_input.fixed.vhd b/tests/generic_map/rule_005_test_input.fixed.vhd index 6d3480b3..eb087b74 100644 --- a/tests/generic_map/rule_005_test_input.fixed.vhd +++ b/tests/generic_map/rule_005_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( +g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, @@ -29,11 +60,57 @@ G_GEN_1 => 3, PORT_3 => w_port_3 ); - U_INST1 : INST1 - generic map ( - G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3 + my_block : block is + generic ( + g_test : BOOLEAN ); + generic map ( +g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( +g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + + U_INST1 : INST1 + generic map ( + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 + ) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_005_test_input.vhd b/tests/generic_map/rule_005_test_input.vhd index c8194ecf..92184a1a 100644 --- a/tests/generic_map/rule_005_test_input.vhd +++ b/tests/generic_map/rule_005_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,33 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map (g_test => c_test + ); + +begin + U_INST1 : INST1 generic map (G_GEN_1 => 3, G_GEN_2 => 4, @@ -28,10 +58,51 @@ begin PORT_3 => w_port_3 ); - U_INST1 : INST1 - generic map ( G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3 + my_block : block is + generic ( + g_test : BOOLEAN ); + generic map (g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map (g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( g_test => c_test + ); + +begin + + U_INST1 : INST1 + generic map ( G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 + ) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( g_test => c_test + ); diff --git a/tests/generic_map/test_rule_005.py b/tests/generic_map/test_rule_005.py index 42ff7b85..9bbc3f89 100644 --- a/tests/generic_map/test_rule_005.py +++ b/tests/generic_map/test_rule_005.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "005") - lExpected = [21, 32] + lExpected = [45, 51, 65, 73, 79, 85, 99, 107] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 6e0b092b1786619f256135b18884a3a251fa7263 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:07:53 +0000 Subject: [PATCH 33/43] Issue#1319: Updated test for rule generic_map_006 to test generic maps other than those in component instantiations. --- .../generic_map/rule_006_test_input.fixed.vhd | 122 ++++++++++++++---- tests/generic_map/rule_006_test_input.vhd | 82 +++++++++++- tests/generic_map/test_rule_006.py | 2 +- 3 files changed, 177 insertions(+), 29 deletions(-) diff --git a/tests/generic_map/rule_006_test_input.fixed.vhd b/tests/generic_map/rule_006_test_input.fixed.vhd index 1d181bfd..79622210 100644 --- a/tests/generic_map/rule_006_test_input.fixed.vhd +++ b/tests/generic_map/rule_006_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,30 +20,99 @@ begin PORT_3 => w_port_3 ); - -- Violations below - - U_INST1 : INST1 + my_block : block is + generic ( + g_test : BOOLEAN + ); generic map ( - G_GEN_1 => 3, - G_GEN_2 => 4, - G_GEN_3 => 5 - ) - port map ( - PORT_1 => w_port_1, - PORT_2 => w_port_2, - PORT_3 => w_port_3 - ); - - U_INST1 : INST1 - generic map ( - G_GEN_1 => 3, - G_GEN_2 => 4, - G_GEN_3 => 5 - ) - port map ( - PORT_1 => w_port_1, - PORT_2 => w_port_2, - PORT_3 => w_port_3 - ); + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + + -- Violations below + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + + U_INST1 : INST1 + generic map ( + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 + ) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + + U_INST1 : INST1 + generic map ( + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 + ) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + diff --git a/tests/generic_map/rule_006_test_input.vhd b/tests/generic_map/rule_006_test_input.vhd index 19c33086..2685e3cc 100644 --- a/tests/generic_map/rule_006_test_input.vhd +++ b/tests/generic_map/rule_006_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map( G_GEN_1 => 3, @@ -27,18 +58,61 @@ begin PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map( + g_test => c_test + ); + + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin U_INST1 : INST1 - generic map ( + generic map ( G_GEN_1 => 3, G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + diff --git a/tests/generic_map/test_rule_006.py b/tests/generic_map/test_rule_006.py index 7540dbff..1c40d418 100644 --- a/tests/generic_map/test_rule_006.py +++ b/tests/generic_map/test_rule_006.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "006") - lExpected = [21, 26, 33, 38] + lExpected = [45, 52, 57, 67, 76, 84, 91, 96, 106, 115] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 51948244ec90dbc78f68ecde688f3b8cfdc93d13 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:12:29 +0000 Subject: [PATCH 34/43] Issue#1319: Removed double newlines in test files. --- tests/generic_map/rule_006_test_input.fixed.vhd | 2 -- tests/generic_map/rule_006_test_input.vhd | 2 -- tests/generic_map/test_rule_006.py | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/generic_map/rule_006_test_input.fixed.vhd b/tests/generic_map/rule_006_test_input.fixed.vhd index 79622210..84a3bfd6 100644 --- a/tests/generic_map/rule_006_test_input.fixed.vhd +++ b/tests/generic_map/rule_006_test_input.fixed.vhd @@ -77,7 +77,6 @@ package my_pkg_g is new my_pkg g_test => c_test ); - architecture ARCH of ENTITY1 is function my_func is new my_func @@ -115,4 +114,3 @@ package my_pkg_g is new my_pkg generic map ( g_test => c_test ); - diff --git a/tests/generic_map/rule_006_test_input.vhd b/tests/generic_map/rule_006_test_input.vhd index 2685e3cc..963565b0 100644 --- a/tests/generic_map/rule_006_test_input.vhd +++ b/tests/generic_map/rule_006_test_input.vhd @@ -77,7 +77,6 @@ package my_pkg_g is new my_pkg g_test => c_test ); - architecture ARCH of ENTITY1 is function my_func is new my_func @@ -115,4 +114,3 @@ package my_pkg_g is new my_pkg generic map ( g_test => c_test ); - diff --git a/tests/generic_map/test_rule_006.py b/tests/generic_map/test_rule_006.py index 1c40d418..f0d4a5e8 100644 --- a/tests/generic_map/test_rule_006.py +++ b/tests/generic_map/test_rule_006.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "006") - lExpected = [45, 52, 57, 67, 76, 84, 91, 96, 106, 115] + lExpected = [45, 52, 57, 67, 76, 83, 90, 95, 105, 114] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 0726be155c4aba865734f51aa114aec204d555dd Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:15:20 +0000 Subject: [PATCH 35/43] Issue#1319: Updated test for rule generic_map_007 to test generic maps other than those in component instantiations. --- .../generic_map/rule_007_test_input.fixed.vhd | 50 +++++++++++++++++- tests/generic_map/rule_007_test_input.vhd | 52 +++++++++++++++++-- tests/generic_map/test_rule_007.py | 2 +- 3 files changed, 98 insertions(+), 6 deletions(-) diff --git a/tests/generic_map/rule_007_test_input.fixed.vhd b/tests/generic_map/rule_007_test_input.fixed.vhd index 833f4bcd..5bf06a17 100644 --- a/tests/generic_map/rule_007_test_input.fixed.vhd +++ b/tests/generic_map/rule_007_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, @@ -24,9 +55,24 @@ begin G_GEN_3 => 5 ) port map ( - PORT_1 => w_port_1, + PORT_1 => w_port_1, PORT_2 =>w_port_2, - PORT_3 => w_port_3 + PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_007_test_input.vhd b/tests/generic_map/rule_007_test_input.vhd index 5572370f..01821e4f 100644 --- a/tests/generic_map/rule_007_test_input.vhd +++ b/tests/generic_map/rule_007_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,18 +20,59 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, G_GEN_2 =>4, - G_GEN_3 => 5 + G_GEN_3 => 5 ) port map ( - PORT_1 => w_port_1, + PORT_1 => w_port_1, PORT_2 =>w_port_2, - PORT_3 => w_port_3 + PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test =>C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/test_rule_007.py b/tests/generic_map/test_rule_007.py index e6775cfe..b624fd47 100644 --- a/tests/generic_map/test_rule_007.py +++ b/tests/generic_map/test_rule_007.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "007") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From f82bf23e0df7fa8c59e726031e88292c1dc90500 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:17:35 +0000 Subject: [PATCH 36/43] Issue#1319: Updated test for rule generic_map_008 to test generic maps other than those in component instantiations. --- tests/generic_map/rule_008_test_input.vhd | 62 ++++++++++++++++++----- tests/generic_map/test_rule_008.py | 2 +- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/tests/generic_map/rule_008_test_input.vhd b/tests/generic_map/rule_008_test_input.vhd index 9c14d0e5..26309c07 100644 --- a/tests/generic_map/rule_008_test_input.vhd +++ b/tests/generic_map/rule_008_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,18 +20,33 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below - U_INST1 : INST1 - generic map( - G_GEN_1 => 3, - 4, - G_GEN_3 => 5 - ) - port map (w_port_1, - PORT_2 => w_port_2, - w_port_3 - ); +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + c_test + ); + +begin U_INST1 : INST1 generic map ( @@ -34,9 +54,25 @@ begin G_GEN_2 => 4, 5 ) - port map (PORT_1 => w_port_1, - w_port_2, + port map ( + w_port_1, + PORT_2 => w_port_2, w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + c_test + ); diff --git a/tests/generic_map/test_rule_008.py b/tests/generic_map/test_rule_008.py index eecd75b6..f1901965 100644 --- a/tests/generic_map/test_rule_008.py +++ b/tests/generic_map/test_rule_008.py @@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "008") - lExpected = [23, 33, 35] + lExpected = [46, 53, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 3c4c94d042da919aa5ef1f7a890199f5c6f9523e Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:18:40 +0000 Subject: [PATCH 37/43] Issue#1319: Removed double newlines in test files. --- tests/generic_map/rule_003_test_input.fixed.vhd | 1 - tests/generic_map/rule_003_test_input.vhd | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/generic_map/rule_003_test_input.fixed.vhd b/tests/generic_map/rule_003_test_input.fixed.vhd index 55222a62..d080c0cc 100644 --- a/tests/generic_map/rule_003_test_input.fixed.vhd +++ b/tests/generic_map/rule_003_test_input.fixed.vhd @@ -119,4 +119,3 @@ package my_pkg_g is new my_pkg g_test => c_test ); - diff --git a/tests/generic_map/rule_003_test_input.vhd b/tests/generic_map/rule_003_test_input.vhd index 743399f7..308dd912 100644 --- a/tests/generic_map/rule_003_test_input.vhd +++ b/tests/generic_map/rule_003_test_input.vhd @@ -119,4 +119,3 @@ package my_pkg_g is new my_pkg ( g_test => c_test ); - From 3654adcf9a4c5a6536218b03e5b09ef757f055ed Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:23:14 +0000 Subject: [PATCH 38/43] Issue#1319: Updated test for rule generic_map_100 to test generic maps other than those in component instantiations. --- .../generic_map/rule_100_test_input.fixed.vhd | 50 ++++++++++++++++++- tests/generic_map/rule_100_test_input.vhd | 50 ++++++++++++++++++- tests/generic_map/test_rule_100.py | 2 +- 3 files changed, 97 insertions(+), 5 deletions(-) diff --git a/tests/generic_map/rule_100_test_input.fixed.vhd b/tests/generic_map/rule_100_test_input.fixed.vhd index 7da5719f..701821fc 100644 --- a/tests/generic_map/rule_100_test_input.fixed.vhd +++ b/tests/generic_map/rule_100_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,10 +20,36 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 - generic map( + generic map ( G_GEN_1 => 3, G_GEN_2 => 4, G_GEN_3 => 5 @@ -27,6 +58,21 @@ begin PORT_1=> w_port_1, PORT_2=> w_port_2, PORT_3=> w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_100_test_input.vhd b/tests/generic_map/rule_100_test_input.vhd index 9f4d9fea..3e4d829b 100644 --- a/tests/generic_map/rule_100_test_input.vhd +++ b/tests/generic_map/rule_100_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,10 +20,36 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test=> c_test + ); + +begin + U_INST1 : INST1 - generic map( + generic map ( G_GEN_1=> 3, G_GEN_2=> 4, G_GEN_3=> 5 @@ -27,6 +58,21 @@ begin PORT_1=> w_port_1, PORT_2=> w_port_2, PORT_3=> w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test=> C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test=> c_test + ); diff --git a/tests/generic_map/test_rule_100.py b/tests/generic_map/test_rule_100.py index ca636270..fadb34d1 100644 --- a/tests/generic_map/test_rule_100.py +++ b/tests/generic_map/test_rule_100.py @@ -23,7 +23,7 @@ class test_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "100") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 5c43dff0086798d6920f170edf3a228adfac8dfe Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:27:57 +0000 Subject: [PATCH 39/43] Issue#1319: Updated test for rule generic_map_600 to test generic maps other than those in component instantiations. --- tests/generic_map/rule_600_test_input.vhd | 51 +++++++++++++++++++++-- tests/generic_map/test_rule_600.py | 4 +- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/tests/generic_map/rule_600_test_input.vhd b/tests/generic_map/rule_600_test_input.vhd index ef8df6e9..303f2ec5 100644 --- a/tests/generic_map/rule_600_test_input.vhd +++ b/tests/generic_map/rule_600_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + test_g => c_test + ); + begin U_INST1 : INST1 @@ -15,13 +20,39 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + test_g : BOOLEAN + ); + generic map ( + test_g => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + test_g => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( - GEN_1_W => 3, - GEN_2 => 4, - GEN_3_WR => 5 + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 ) port map ( PORT_1 => w_port_1, @@ -29,5 +60,19 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/test_rule_600.py b/tests/generic_map/test_rule_600.py index ae04d30a..8cf8a7c6 100644 --- a/tests/generic_map/test_rule_600.py +++ b/tests/generic_map/test_rule_600.py @@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "600") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -35,7 +35,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "600") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From b0da9824ea3cb2e6a7ab0af4517517716a0e5100 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:31:47 +0000 Subject: [PATCH 40/43] Issue#1319: Updated test for rule generic_map_601 to test generic maps other than those in component instantiations. --- tests/generic_map/rule_601_test_input.vhd | 58 ++++++++++++++++++++--- tests/generic_map/test_rule_601.py | 4 +- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/tests/generic_map/rule_601_test_input.vhd b/tests/generic_map/rule_601_test_input.vhd index 798b6924..e30ff735 100644 --- a/tests/generic_map/rule_601_test_input.vhd +++ b/tests/generic_map/rule_601_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,13 +20,39 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + test_g => c_test + ); + +begin + U_INST1 : INST1 generic map ( - W_GEN_1 => 3, - GEN_2 => 4, - WR_GEN_3 => 5 + GEN_1_G => 3, + GEN_2_G => 4, + GEN_3_G => 5 ) port map ( PORT_1 => w_port_1, @@ -30,9 +61,24 @@ begin ); U_INST2 : INST2 - generic map ( - W_GEN_1(W_GEN_1) => 3, - G_GEN_2(W_GEN_1) => 10 + generic map ( + W_GEN_1(W_GEN_1) => 3, + G_GEN_2(W_GEN_1) => 10 + ); + + my_block : block is + generic ( + test_g : BOOLEAN ); + generic map ( + test_g => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + test_g => c_test + ); diff --git a/tests/generic_map/test_rule_601.py b/tests/generic_map/test_rule_601.py index fb29a7cb..2c329cfb 100644 --- a/tests/generic_map/test_rule_601.py +++ b/tests/generic_map/test_rule_601.py @@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "601") - lExpected = [22, 23, 24, 34] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -35,7 +35,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "601") - lExpected = [22, 23, 24, 34] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 45a457e7efd92b907818ac074e2c966b943430d1 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Fri, 15 Nov 2024 14:32:03 +0000 Subject: [PATCH 41/43] Issue#1319: Slight improvement to test for rule generic_map_600. --- tests/generic_map/rule_600_test_input.vhd | 6 ++++++ tests/generic_map/test_rule_600.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/generic_map/rule_600_test_input.vhd b/tests/generic_map/rule_600_test_input.vhd index 303f2ec5..f029c6f6 100644 --- a/tests/generic_map/rule_600_test_input.vhd +++ b/tests/generic_map/rule_600_test_input.vhd @@ -60,6 +60,12 @@ begin PORT_3 => w_port_3 ); + U_INST2 : INST2 + generic map ( + GEN_1_W(W_GEN_1) => 3, + GEN_2_G(W_GEN_1) => 10 + ); + my_block : block is generic ( g_test : BOOLEAN diff --git a/tests/generic_map/test_rule_600.py b/tests/generic_map/test_rule_600.py index 8cf8a7c6..4c179a0d 100644 --- a/tests/generic_map/test_rule_600.py +++ b/tests/generic_map/test_rule_600.py @@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "600") - lExpected = [46, 53, 54, 55, 68, 77] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -35,7 +35,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "600") - lExpected = [46, 53, 54, 55, 68, 77] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 5e56a0c37463d87dc9af45d00173fdbdd7ab247d Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 12 Dec 2024 02:07:22 +0000 Subject: [PATCH 42/43] Issue#1319: Updated tests for generic_map_006 --- tests/generic_map/rule_006_test_input.fixed.vhd | 2 +- tests/generic_map/test_rule_006.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/generic_map/rule_006_test_input.fixed.vhd b/tests/generic_map/rule_006_test_input.fixed.vhd index 584bbe33..2b6f1efe 100644 --- a/tests/generic_map/rule_006_test_input.fixed.vhd +++ b/tests/generic_map/rule_006_test_input.fixed.vhd @@ -92,7 +92,7 @@ begin G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 diff --git a/tests/generic_map/test_rule_006.py b/tests/generic_map/test_rule_006.py index f0d4a5e8..f9f456d7 100644 --- a/tests/generic_map/test_rule_006.py +++ b/tests/generic_map/test_rule_006.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "006") - lExpected = [45, 52, 57, 67, 76, 83, 90, 95, 105, 114] + lExpected = [45, 52, 67, 76, 83, 90, 105, 114] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) From 7607f4feac8b44cbd9dc96940f9ec335d8735cda Mon Sep 17 00:00:00 2001 From: Jukka Hertzog Date: Thu, 12 Dec 2024 10:40:50 +0000 Subject: [PATCH 43/43] Issue#1287: Updated tests to check that declarations outisde of protected type bodies are ignore by protected type body rules. --- tests/protected_type_body/rule_400_test_input.fixed.vhd | 5 +++++ tests/protected_type_body/rule_400_test_input.vhd | 5 +++++ tests/protected_type_body/rule_401_test_input.fixed.vhd | 3 +++ tests/protected_type_body/rule_401_test_input.vhd | 3 +++ tests/protected_type_body/rule_402_test_input.fixed.vhd | 5 +++++ tests/protected_type_body/rule_402_test_input.vhd | 5 +++++ tests/protected_type_body/test_rule_400.py | 2 +- 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/protected_type_body/rule_400_test_input.fixed.vhd b/tests/protected_type_body/rule_400_test_input.fixed.vhd index 73384f03..c8e90f93 100644 --- a/tests/protected_type_body/rule_400_test_input.fixed.vhd +++ b/tests/protected_type_body/rule_400_test_input.fixed.vhd @@ -62,6 +62,11 @@ package body RTL is begin end function; end protected body; + + constant c_cons1 : std_logic; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + end package body RTL; -- Test functions and procedures defined in protected body diff --git a/tests/protected_type_body/rule_400_test_input.vhd b/tests/protected_type_body/rule_400_test_input.vhd index 155ec388..b125bac0 100644 --- a/tests/protected_type_body/rule_400_test_input.vhd +++ b/tests/protected_type_body/rule_400_test_input.vhd @@ -62,6 +62,11 @@ package body RTL is begin end function; end protected body; + + constant c_cons1 : std_logic; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + end package body RTL; -- Test functions and procedures defined in protected body diff --git a/tests/protected_type_body/rule_401_test_input.fixed.vhd b/tests/protected_type_body/rule_401_test_input.fixed.vhd index 2f05bd39..cef9204b 100644 --- a/tests/protected_type_body/rule_401_test_input.fixed.vhd +++ b/tests/protected_type_body/rule_401_test_input.fixed.vhd @@ -27,4 +27,7 @@ package body RTL is end function; end protected body; + constant c_cons1 : std_logic; + constant c_cons_longer : std_logic; + end package body RTL; diff --git a/tests/protected_type_body/rule_401_test_input.vhd b/tests/protected_type_body/rule_401_test_input.vhd index 5604f06e..d195f65a 100644 --- a/tests/protected_type_body/rule_401_test_input.vhd +++ b/tests/protected_type_body/rule_401_test_input.vhd @@ -27,4 +27,7 @@ package body RTL is end function; end protected body; + constant c_cons1 : std_logic; + constant c_cons_longer : std_logic; + end package body RTL; diff --git a/tests/protected_type_body/rule_402_test_input.fixed.vhd b/tests/protected_type_body/rule_402_test_input.fixed.vhd index 00026366..c62e4aff 100644 --- a/tests/protected_type_body/rule_402_test_input.fixed.vhd +++ b/tests/protected_type_body/rule_402_test_input.fixed.vhd @@ -14,4 +14,9 @@ package body RTL is begin end procedure; end protected body; + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + end package body RTL; diff --git a/tests/protected_type_body/rule_402_test_input.vhd b/tests/protected_type_body/rule_402_test_input.vhd index f9468f7e..7285dd49 100644 --- a/tests/protected_type_body/rule_402_test_input.vhd +++ b/tests/protected_type_body/rule_402_test_input.vhd @@ -14,4 +14,9 @@ package body RTL is begin end procedure; end protected body; + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + end package body RTL; diff --git a/tests/protected_type_body/test_rule_400.py b/tests/protected_type_body/test_rule_400.py index 590a786e..53b45860 100644 --- a/tests/protected_type_body/test_rule_400.py +++ b/tests/protected_type_body/test_rule_400.py @@ -28,7 +28,7 @@ class test_protected_type_body_rule(unittest.TestCase): self.assertEqual(oRule.identifier, "400") lExpected = [] - lExpected.extend([7, 8, 9, 10, 21, 22, 23, 25, 26, 30, 31, 44, 90, 91, 92]) + lExpected.extend([7, 8, 9, 10, 21, 22, 23, 25, 26, 30, 31, 44, 95, 96, 97]) oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))