Issue#1323: Added tests for indent rule for package instantiations.

This commit is contained in:
JHertz5 2024-11-13 19:32:28 +00:00
parent aad4541901
commit bce8204174
3 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,11 @@
package my_pkg is new my_generic_pkg
generic map (
g_my_generic => 2
);
package my_pkg is new my_generic_pkg
generic map (
g_my_generic => 2
);

View File

@ -0,0 +1,11 @@
package my_pkg is new my_generic_pkg
generic map (
g_my_generic => 2
);
package my_pkg is new my_generic_pkg
generic map (
g_my_generic => 2
);

View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
import os
import unittest
from tests import utils
from vsg import vhdlFile
from vsg.rules import package_instantiation
sTestDir = os.path.dirname(__file__)
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_300_test_input.vhd"))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_300_test_input.fixed.vhd"), lExpected)
class test_package_instantiation_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)
self.oFile.set_indent_map(dIndentMap)
def test_rule_300(self):
oRule = package_instantiation.rule_300()
oRule.allow_comments = True
self.assertTrue(oRule)
self.assertEqual(oRule.name, "package_instantiation")
self.assertEqual(oRule.identifier, "300")
lExpected = [7]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_300(self):
oRule = package_instantiation.rule_300()
oRule.allow_comments = True
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])