Updates for issue #172
Fixed mis-classification of less than or equal to (<=) in concurrent statements: 1) Updated tests
This commit is contained in:
parent
0a4b99b3e5
commit
95b6f907c8
|
|
@ -48,7 +48,7 @@ class keyword_alignment_rule(rule.rule):
|
|||
iStartGroupIndex = iLineNumber
|
||||
if not oLine.__dict__[self.sEndGroupTrigger] and fGroupFound:
|
||||
fGroupFound = False
|
||||
check.keyword_alignment(self, iStartGroupIndex, self.sKeyword, lGroup)
|
||||
concurrent_keyword_alignment(self, iStartGroupIndex, self.sKeyword, lGroup)
|
||||
lGroup = []
|
||||
iStartGroupIndex = None
|
||||
if fGroupFound:
|
||||
|
|
@ -56,3 +56,38 @@ class keyword_alignment_rule(rule.rule):
|
|||
|
||||
def _fix_violations(self, oFile):
|
||||
fix.keyword_alignment(self, oFile)
|
||||
|
||||
|
||||
def concurrent_keyword_alignment(self, iLineNumber, sKeyword, lGroup):
|
||||
'''
|
||||
Checks keywords in a group of line objects are aligned in the same column.
|
||||
|
||||
Parameters:
|
||||
|
||||
self: (rule object)
|
||||
|
||||
iLineNumber: (integer)
|
||||
|
||||
sKeyword: (string)
|
||||
|
||||
lGroup: (list of line objects)
|
||||
'''
|
||||
iKeywordAlignment = None
|
||||
iMaximumKeywordColumn = 0
|
||||
sViolationRange = str(iLineNumber) + '-' + str(iLineNumber + len(lGroup) - 1)
|
||||
self.dFix['violations'][sViolationRange] = {}
|
||||
self.dFix['violations'][sViolationRange]['line'] = {}
|
||||
|
||||
for iIndex, oGroupLine in enumerate(lGroup):
|
||||
if sKeyword in oGroupLine.line and oGroupLine.isConcurrentBegin:
|
||||
self.dFix['violations'][sViolationRange]['line'][iLineNumber + iIndex] = {}
|
||||
self.dFix['violations'][sViolationRange]['line'][iLineNumber + iIndex]['keywordColumn'] = oGroupLine.line.find(sKeyword)
|
||||
|
||||
iMaximumKeywordColumn = check.get_maximum_keyword_column(oGroupLine, sKeyword, iMaximumKeywordColumn)
|
||||
|
||||
iKeywordAlignment = check.update_keyword_alignment(oGroupLine, sKeyword, iKeywordAlignment)
|
||||
|
||||
if not iKeywordAlignment == oGroupLine.line.find(sKeyword):
|
||||
check.add_range_violation(self, sViolationRange)
|
||||
|
||||
self.dFix['violations'][sViolationRange]['maximumKeywordColumn'] = iMaximumKeywordColumn
|
||||
|
|
|
|||
|
|
@ -47,4 +47,11 @@ label:a<=b;
|
|||
|
||||
a <= b when g = '1' else '1'; -- Not an error
|
||||
|
||||
a <= b when g = '1' else
|
||||
c when g => 10 else
|
||||
d when g <= 20 else
|
||||
e when g < 5 else
|
||||
f when g > 13 else
|
||||
z;
|
||||
|
||||
end architecture ARCH;
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
self.assertEqual(lActual, lExpected)
|
||||
|
||||
def test_insideConcurrent_assignment(self):
|
||||
lExpected = [6,7,8,9,10,11,23,24,26,27,28,29,30,32,33,34,35,36,38,39,40,41,42,44,45,46,48]
|
||||
lExpected = [6,7,8,9,10,11,23,24,26,27,28,29,30,32,33,34,35,36,38,39,40,41,42,44,45,46,48,50,51,52,53,54,55]
|
||||
# Generic actual list
|
||||
lActual = []
|
||||
for iIndex, oLine in enumerate(oFileConcurrent.lines):
|
||||
|
|
@ -298,7 +298,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
self.assertEqual(lActual, lExpected)
|
||||
|
||||
def test_isConcurrentBegin_assignment(self):
|
||||
lExpected = [6,7,8,9,11,23,24,26,32,33,34,35,38,39,42,44,45,48]
|
||||
lExpected = [6,7,8,9,11,23,24,26,32,33,34,35,38,39,42,44,45,48,50]
|
||||
# Generic actual list
|
||||
lActual = []
|
||||
for iIndex, oLine in enumerate(oFileConcurrent.lines):
|
||||
|
|
@ -308,7 +308,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
self.assertEqual(lActual, lExpected)
|
||||
|
||||
def test_isEndConcurrent_assignment(self):
|
||||
lExpected = [6,7,8,10,11,23,24,30,32,33,34,36,38,41,42,44,46,48]
|
||||
lExpected = [6,7,8,10,11,23,24,30,32,33,34,36,38,41,42,44,46,48,55]
|
||||
# Generic actual list
|
||||
lActual = []
|
||||
for iIndex, oLine in enumerate(oFileConcurrent.lines):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ def concurrent(dVars, oLine):
|
|||
if not (oLine.insideArchitecture and not oLine.insideProcess):
|
||||
return
|
||||
if re.match('^\s*\w+.*\s*<=', oLine.lineNoComment) or re.match('^\s*\w+\s*:\s*\w+.*\s*<=', oLine.lineNoComment):
|
||||
if not oLine.insideAssert:
|
||||
if not oLine.insideAssert and not oLine.insideConcurrent:
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
oLine.isConcurrentBegin = True
|
||||
oLine.insideConcurrent = True
|
||||
|
|
|
|||
Loading…
Reference in New Issue