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
This commit is contained in:
Jeremiah C Leary 2019-10-15 18:06:09 -05:00
parent f253b18f81
commit c71e025878
6 changed files with 20 additions and 9 deletions

View File

@ -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)

View File

@ -7,7 +7,7 @@ begin
end architecture RTL;
-- This is not valid
architecture ENTITY1 of ENTITY1 is
architecture ENTITY1 of entity1 is
begin

View File

@ -77,3 +77,9 @@ begin
end;
-- Comment
architecture ARCH of arch is
begin
end architecture ARCH;

View File

@ -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):

View File

@ -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)

View File

@ -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):