From c71e025878e8a3fc256d53c28e2b7efeaa09dae0 Mon Sep 17 00:00:00 2001 From: Jeremiah C Leary Date: Tue, 15 Oct 2019 18:06:09 -0500 Subject: [PATCH] Updates for issue #258 Rule architecture_014 would not uppercase the entity name if it matched the architecture name. 1) Updated tests 2) Updated rule architecture_014 --- vsg/rules/architecture/architecture_case_rule.py | 7 ++++++- vsg/tests/architecture/architecture_name_test_input.vhd | 2 +- vsg/tests/architecture/architecture_test_input.vhd | 6 ++++++ vsg/tests/architecture/test_fix_rule_architecture.py | 4 ++-- vsg/tests/architecture/test_rule_architecture.py | 2 +- vsg/tests/vhdlFile/test_vhdlFile.py | 8 ++++---- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/vsg/rules/architecture/architecture_case_rule.py b/vsg/rules/architecture/architecture_case_rule.py index 34a6febc..6189b5cf 100644 --- a/vsg/rules/architecture/architecture_case_rule.py +++ b/vsg/rules/architecture/architecture_case_rule.py @@ -23,4 +23,9 @@ class architecture_case_rule(rule.rule): def _fix_violations(self, oFile): for iLineNumber in self.violations: - fix.upper_case(self, oFile.lines[iLineNumber], oFile.lines[iLineNumber].line.split()[self.iIndex]) + oLine = oFile.lines[iLineNumber] + sLine = oLine.lineNoComment + sWord = sLine.split()[self.iIndex] + iIndex = sLine.rfind(sLine.split()[self.iIndex]) + sLine = sLine[:iIndex] + sWord.upper() + sLine[iIndex + len(sWord):] + oLine.update_line(sLine) diff --git a/vsg/tests/architecture/architecture_name_test_input.vhd b/vsg/tests/architecture/architecture_name_test_input.vhd index 594049a3..2b672056 100644 --- a/vsg/tests/architecture/architecture_name_test_input.vhd +++ b/vsg/tests/architecture/architecture_name_test_input.vhd @@ -7,7 +7,7 @@ begin end architecture RTL; -- This is not valid -architecture ENTITY1 of ENTITY1 is +architecture ENTITY1 of entity1 is begin diff --git a/vsg/tests/architecture/architecture_test_input.vhd b/vsg/tests/architecture/architecture_test_input.vhd index c233d947..aba0ad61 100644 --- a/vsg/tests/architecture/architecture_test_input.vhd +++ b/vsg/tests/architecture/architecture_test_input.vhd @@ -77,3 +77,9 @@ begin end; -- Comment + +architecture ARCH of arch is + +begin + +end architecture ARCH; diff --git a/vsg/tests/architecture/test_fix_rule_architecture.py b/vsg/tests/architecture/test_fix_rule_architecture.py index 2a2d5b3a..c068cfe3 100644 --- a/vsg/tests/architecture/test_fix_rule_architecture.py +++ b/vsg/tests/architecture/test_fix_rule_architecture.py @@ -13,14 +13,13 @@ oFileRule010 = vhdlFile.vhdlFile(lFileRule010) lFileIs = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'architecture_is_test_input.vhd')) oFileIs = vhdlFile.vhdlFile(lFileIs) +lFile = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'architecture_test_input.vhd')) class testFixRuleArchitectureMethods(unittest.TestCase): def setUp(self): - lFile = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'architecture_test_input.vhd')) self.oFile = vhdlFile.vhdlFile(lFile) - def test_fix_rule_001(self): oRule = architecture.rule_001() dExpected = [] @@ -121,6 +120,7 @@ class testFixRuleArchitectureMethods(unittest.TestCase): dExpected = [] oRule.fix(self.oFile) oRule.analyze(self.oFile) + self.assertEqual(self.oFile.lines[81].line, 'architecture ARCH of ARCH is') self.assertEqual(oRule.violations, dExpected) def test_fix_rule_015(self): diff --git a/vsg/tests/architecture/test_rule_architecture.py b/vsg/tests/architecture/test_rule_architecture.py index df0790e4..416f2362 100644 --- a/vsg/tests/architecture/test_rule_architecture.py +++ b/vsg/tests/architecture/test_rule_architecture.py @@ -175,7 +175,7 @@ class testRuleArchitectureMethods(unittest.TestCase): self.assertTrue(oRule) self.assertEqual(oRule.name, 'architecture') self.assertEqual(oRule.identifier, '014') - dExpected = [9,20] + dExpected = [9,20,81] oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected) diff --git a/vsg/tests/vhdlFile/test_vhdlFile.py b/vsg/tests/vhdlFile/test_vhdlFile.py index d2a2170c..3909d99f 100644 --- a/vsg/tests/vhdlFile/test_vhdlFile.py +++ b/vsg/tests/vhdlFile/test_vhdlFile.py @@ -224,7 +224,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_insideArchitecture_assignment(self): - lExpected = [3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,26,27,28,29,30,31,33,34,35,37,38,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77] + lExpected = [3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,26,27,28,29,30,31,33,34,35,37,38,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,81,82,83,84,85] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileArchitecture.lines): @@ -234,7 +234,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_isArchitectureBegin_assignment(self): - lExpected = [5,11,16,22,29,34,39,49,61] + lExpected = [5,11,16,22,29,34,39,49,61,83] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileArchitecture.lines): @@ -244,7 +244,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_isArchitectureKeyword_assignment(self): - lExpected = [3,9,14,20,26,33,37,47,59] + lExpected = [3,9,14,20,26,33,37,47,59,81] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileArchitecture.lines): @@ -254,7 +254,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_isEndArchitecture_assignment(self): - lExpected = [7,13,18,24,31,35,45,55,77] + lExpected = [7,13,18,24,31,35,45,55,77,85] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileArchitecture.lines):