def test_fix_012(self): oRule = whitespace.rule_012() self.assertTrue(oRule) lFile = utils.read_vhdlfile(sFileName) oFile = vhdlFile.vhdlFile(lFile) dExpected = [] oFile.lines.append(line.line(' a <= b;')) #1 oFile.lines.append(line.blank_line()) #2 oFile.lines.append(line.blank_line()) #3 oFile.lines.append(line.blank_line()) #4 oFile.lines.append(line.blank_line()) #5 oFile.lines.append(line.line(' c <= d;')) #6 oFile.lines.append(line.line(' a <= b;')) #7 oFile.lines.append(line.blank_line()) #8 oFile.lines.append(line.line(' c <= d;')) #9 oFile.lines.append(line.blank_line()) #10 oFile.lines.append(line.blank_line()) #11 oFile.lines.append(line.line(' a <= b;')) #12 oRule.fix(oFile) oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected) self.assertEqual(oFile.lines[1].line,' a <= b;') #1 self.assertEqual(oFile.lines[2].isBlank,True) #2 self.assertEqual(oFile.lines[3].line,' c <= d;') #3 self.assertEqual(oFile.lines[4].line,' a <= b;') #4 self.assertEqual(oFile.lines[5].isBlank,True) #5 self.assertEqual(oFile.lines[6].line,' c <= d;') #6 self.assertEqual(oFile.lines[7].isBlank,True) #7 self.assertEqual(oFile.lines[8].line,' a <= b;') #8
def test_012(self): oRule = whitespace.rule_012() self.assertTrue(oRule) self.assertEqual(oRule.name, 'whitespace') self.assertEqual(oRule.identifier, '012') self.assertEqual(oRule.phase, 3) lExpected = [] dViolation = utils.add_violation(2) dViolation['remove'] = 3 lExpected.append(dViolation) dViolation = utils.add_violation(10) dViolation['remove'] = 1 lExpected.append(dViolation) # dExpected = [2,10] # dExpected = [{'lineNumber': 2, 'remove': 3}, # {'lineNumber': 10, 'remove': 1}] self.oFile.lines.append(line.line(' a <= b;')) #1 self.oFile.lines.append(line.blank_line()) #2 self.oFile.lines.append(line.blank_line()) #3 self.oFile.lines.append(line.blank_line()) #4 self.oFile.lines.append(line.blank_line()) #5 self.oFile.lines.append(line.line(' c <= d;')) #6 self.oFile.lines.append(line.line(' a <= b;')) #7 self.oFile.lines.append(line.blank_line()) #8 self.oFile.lines.append(line.line(' c <= d;')) #9 self.oFile.lines.append(line.blank_line()) #10 self.oFile.lines.append(line.blank_line()) #11 self.oFile.lines.append(line.line(' a <= b;')) #12 oRule.analyze(self.oFile) self.assertEqual(oRule.violations, lExpected)
def test_fix_rule_012_2_allowed(self): oRule = whitespace.rule_012() oRule.numBlankLines = 2 oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected_2_allowed, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
def test_rule_012_2_allowed(self): oRule = whitespace.rule_012() oRule.numBlankLines = 2 self.assertTrue(oRule) self.assertEqual(oRule.name, 'whitespace') self.assertEqual(oRule.identifier, '012') lExpected_2_allowed = [6] oRule.analyze(self.oFile) self.assertEqual( lExpected_2_allowed, utils.extract_violation_lines_from_violation_object( oRule.violations))
def test_012(self): oRule = whitespace.rule_012() self.assertTrue(oRule) self.assertEqual(oRule.name, 'whitespace') self.assertEqual(oRule.identifier, '012') self.assertEqual(oRule.phase, 3) dExpected = [2, 10] self.oFile.lines.append(line.line(' a <= b;')) #1 self.oFile.lines.append(line.blank_line()) #2 self.oFile.lines.append(line.blank_line()) #3 self.oFile.lines.append(line.blank_line()) #4 self.oFile.lines.append(line.blank_line()) #5 self.oFile.lines.append(line.line(' c <= d;')) #6 self.oFile.lines.append(line.line(' a <= b;')) #7 self.oFile.lines.append(line.blank_line()) #8 self.oFile.lines.append(line.line(' c <= d;')) #9 self.oFile.lines.append(line.blank_line()) #10 self.oFile.lines.append(line.blank_line()) #11 self.oFile.lines.append(line.line(' a <= b;')) #12 oRule.analyze(self.oFile) self.assertEqual(oRule.violations, dExpected)
def test_012(self): oRule = whitespace.rule_012() self.assertTrue(oRule) self.assertEqual(oRule.name, 'whitespace') self.assertEqual(oRule.identifier, '012') self.assertEqual(oRule.phase, 3) oFile = vhdlFile.vhdlFile(sFileName) dExpected = [2, 10] oFile.lines.append(line.line(' a <= b;')) #1 oFile.lines.append(line.blank_line()) #2 oFile.lines.append(line.blank_line()) #3 oFile.lines.append(line.blank_line()) #4 oFile.lines.append(line.blank_line()) #5 oFile.lines.append(line.line(' c <= d;')) #6 oFile.lines.append(line.line(' a <= b;')) #7 oFile.lines.append(line.blank_line()) #8 oFile.lines.append(line.line(' c <= d;')) #9 oFile.lines.append(line.blank_line()) #10 oFile.lines.append(line.blank_line()) #11 oFile.lines.append(line.line(' a <= b;')) #12 oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected)