Ejemplo n.º 1
0
    def test_rule_004(self):
        oRule = whitespace.rule_004()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '004')

        lExpected = [5, 12, 13, 17]

        oRule.analyze(self.oFile)
        self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
Ejemplo n.º 2
0
    def test_fix_rule_004(self):
        oRule = whitespace.rule_004()

        oRule.fix(self.oFile)

        lActual = self.oFile.get_lines()

        self.assertEqual(lExpected, lActual)

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, [])
Ejemplo n.º 3
0
    def test_004(self):
        oRule = whitespace.rule_004()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '004')
        self.assertEqual(oRule.phase, 2)

        dExpected = utils.add_violation_list([2,4,6])
        self.oFile.lines.append(line.line('  This is a test of commas,'))
        self.oFile.lines.append(line.line('  This is a test of commas ,'))
        self.oFile.lines.append(line.line('  This is a test of commas,'))
        self.oFile.lines.append(line.line('  This is a test of commas    ,'))
        self.oFile.lines.append(line.line('  This is a test, of commas'))
        self.oFile.lines.append(line.line('  This is a test , of commas'))
        self.oFile.lines.append(line.line('  This is a test, of commas -- This is a comment ,'))
        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
    def test_fix_004(self):
        oRule = whitespace.rule_004()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '004')

        oFile = vhdlFile.vhdlFile(sFileName)

        dExpected = []
        oFile.lines.append(line.line('  This is a test of commas,'))
        oFile.lines.append(line.line('  This is a test of commas ,'))
        oFile.lines.append(line.line('  This is a test of commas,'))
        oFile.lines.append(line.line('  This is a test of commas    ,'))
        oFile.lines.append(line.line('  This is a test, of commas'))
        oFile.lines.append(line.line('  This is a test , of commas'))
        oFile.lines.append(line.line('  This is a test, of commas -- This is a comment ,'))
        oRule.fix(oFile)
        oRule.analyze(oFile)
        self.assertEqual(oRule.violations, dExpected)
        self.assertEqual(oFile.lines[7].line, '  This is a test, of commas -- This is a comment ,')