コード例 #1
0
    def test_rule_011(self):
        oRule = whitespace.rule_011()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '011')

        lExpected = []
        lExpected.extend(range(23, 26))
        lExpected.extend(range(27, 30))
        lExpected.extend(range(31, 34))
        lExpected.extend(range(35, 38))
        lExpected.extend(range(39, 42))
        lExpected.extend(range(43, 46))
        lExpected.extend(range(47, 50))
        lExpected.extend(range(51, 54))
        lExpected.extend(range(55, 58))
        lExpected.extend(range(59, 62))
        lExpected.extend(range(63, 65))

        #        utils.print_objects(self.oFile,True)

        oRule.analyze(self.oFile)
        self.assertEqual(
            lExpected,
            utils.extract_violation_lines_from_violation_object(
                oRule.violations))
コード例 #2
0
    def test_fix_rule_011(self):
        oRule = whitespace.rule_011()

        oRule.fix(self.oFile)

        lActual = self.oFile.get_lines()

        self.assertEqual(lExpected, lActual)

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, [])
コード例 #3
0
    def test_011_with_negative_numbers(self):
        oRule = whitespace.rule_011()

        dExpected = [utils.add_violation(7)]
        self.oFile.lines.append(line.line('  for i in -32768 to 32767 loop')) #1
        self.oFile.lines.append(line.line('  a <= b -32768')) #2
        self.oFile.lines.append(line.line('  a <= c + -32768')) #3
        self.oFile.lines.append(line.line('  a <= to -32768')) #4
        self.oFile.lines.append(line.line('  a <= (-32 downto -568)')) #5
        self.oFile.lines.append(line.line('  a <= c_constant -144')) #6
        self.oFile.lines.append(line.line('  a <= c_constant -144_stuff')) #7

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
コード例 #4
0
    def test_011(self):
        oRule = whitespace.rule_011()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '011')
        self.assertEqual(oRule.phase, 2)

        dExpected = [
            1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 23, 24, 26
        ]
        self.oFile.lines.append(line.line('  a <= b+ c'))  #1
        self.oFile.lines.append(line.line('  a <= b +c'))  #2
        self.oFile.lines.append(line.line('  a <= b + c'))  #3
        self.oFile.lines.append(line.line('  a <= b+c'))  #4
        self.oFile.lines.append(line.line('  a <= b- c'))  #5
        self.oFile.lines.append(line.line('  a <= b -c'))  #6
        self.oFile.lines.append(line.line('  a <= b - c'))  #7
        self.oFile.lines.append(line.line('  a <= b-c'))  #8
        self.oFile.lines.append(line.line('  a <= b/ c'))  #9
        self.oFile.lines.append(line.line('  a <= b /c'))  #10
        self.oFile.lines.append(line.line('  a <= b / c'))  #11
        self.oFile.lines.append(line.line('  a <= b/c'))  #12
        self.oFile.lines.append(line.line('  a <= b* c'))  #13
        self.oFile.lines.append(line.line('  a <= b *c'))  #14
        self.oFile.lines.append(line.line('  a <= b * c'))  #15
        self.oFile.lines.append(line.line('  a <= b*c'))  #16
        self.oFile.lines.append(line.line('  a <= b** c'))  #17
        self.oFile.lines.append(line.line('  a <= b **c'))  #18
        self.oFile.lines.append(line.line('  a <= b ** c'))  #19
        self.oFile.lines.append(line.line('  a <= b**c'))  #20
        self.oFile.lines.append(line.line('  a <= b**c -- This**is fine'))  #21
        self.oFile.lines.append(
            line.line('  a <= b ** c -- This**is fine'))  #22
        self.oFile.lines.append(line.line('  a <= )+ ('))  #23
        self.oFile.lines.append(line.line('  a <= ) +('))  #24
        self.oFile.lines.append(line.line('  a <= ) + ('))  #25
        self.oFile.lines.append(line.line('  a <= )+('))  #26
        self.oFile.lines.append(
            line.line('  G_FILE => "$DIR/somedir/somefile.txt",'))  #27
        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
コード例 #5
0
    def test_011(self):
        oRule = whitespace.rule_011()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '011')
        self.assertEqual(oRule.phase, 2)

        oFile = vhdlFile.vhdlFile(sFileName)

        dExpected = [
            1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 23, 24, 26
        ]
        oFile.lines.append(line.line('  a <= b+ c'))  #1
        oFile.lines.append(line.line('  a <= b +c'))  #2
        oFile.lines.append(line.line('  a <= b + c'))  #3
        oFile.lines.append(line.line('  a <= b+c'))  #4
        oFile.lines.append(line.line('  a <= b- c'))  #5
        oFile.lines.append(line.line('  a <= b -c'))  #6
        oFile.lines.append(line.line('  a <= b - c'))  #7
        oFile.lines.append(line.line('  a <= b-c'))  #8
        oFile.lines.append(line.line('  a <= b/ c'))  #9
        oFile.lines.append(line.line('  a <= b /c'))  #10
        oFile.lines.append(line.line('  a <= b / c'))  #11
        oFile.lines.append(line.line('  a <= b/c'))  #12
        oFile.lines.append(line.line('  a <= b* c'))  #13
        oFile.lines.append(line.line('  a <= b *c'))  #14
        oFile.lines.append(line.line('  a <= b * c'))  #15
        oFile.lines.append(line.line('  a <= b*c'))  #16
        oFile.lines.append(line.line('  a <= b** c'))  #17
        oFile.lines.append(line.line('  a <= b **c'))  #18
        oFile.lines.append(line.line('  a <= b ** c'))  #19
        oFile.lines.append(line.line('  a <= b**c'))  #20
        oFile.lines.append(line.line('  a <= b**c -- This**is fine'))  #21
        oFile.lines.append(line.line('  a <= b ** c -- This**is fine'))  #22
        oFile.lines.append(line.line('  a <= )+ ('))  #23
        oFile.lines.append(line.line('  a <= ) +('))  #24
        oFile.lines.append(line.line('  a <= ) + ('))  #25
        oFile.lines.append(line.line('  a <= )+('))  #26
        oRule.analyze(oFile)
        self.assertEqual(oRule.violations, dExpected)
コード例 #6
0
    def test_fix_011(self):
        oRule = whitespace.rule_011()

        lFile = utils.read_vhdlfile(sFileName)
        oFile = vhdlFile.vhdlFile(lFile)

        dExpected = []
        oFile.lines.append(line.line('  a <= b+ c'))   #1
        oFile.lines.append(line.line('  a <= b +c'))   #2
        oFile.lines.append(line.line('  a <= b + c'))  #3
        oFile.lines.append(line.line('  a <= b+c'))    #4
        oFile.lines.append(line.line('  a <= b- c'))   #5
        oFile.lines.append(line.line('  a <= b -c'))   #6
        oFile.lines.append(line.line('  a <= b - c'))  #7
        oFile.lines.append(line.line('  a <= b-c'))    #8
        oFile.lines.append(line.line('  a <= b/ c'))   #9
        oFile.lines.append(line.line('  a <= b /c'))   #10
        oFile.lines.append(line.line('  a <= b / c'))  #11
        oFile.lines.append(line.line('  a <= b/c'))    #12
        oFile.lines.append(line.line('  a <= b* c'))   #13
        oFile.lines.append(line.line('  a <= b *c'))   #14
        oFile.lines.append(line.line('  a <= b * c'))  #15
        oFile.lines.append(line.line('  a <= b*c'))    #16
        oFile.lines.append(line.line('  a <= b** c'))   #17
        oFile.lines.append(line.line('  a <= b **c'))   #18
        oFile.lines.append(line.line('  a <= b ** c'))  #19
        oFile.lines.append(line.line('  a <= b**c'))    #20
        oFile.lines.append(line.line('  a <= b**c -- This**is fine'))    #21
        oFile.lines.append(line.line('  a <= b ** c -- This**is fine'))    #22
        oFile.lines.append(line.line('  a <= )+ ('))   #23
        oFile.lines.append(line.line('  a <= ) +('))   #24
        oFile.lines.append(line.line('  a <= ) + ('))  #25
        oFile.lines.append(line.line('  a <= )+('))    #26
        oRule.fix(oFile)
        oRule.analyze(oFile)
        self.assertEqual(oRule.violations, dExpected)
        self.assertEqual(oFile.lines[1].line, '  a <= b + c')
        self.assertEqual(oFile.lines[2].line, '  a <= b + c')
        self.assertEqual(oFile.lines[3].line, '  a <= b + c')
        self.assertEqual(oFile.lines[4].line, '  a <= b + c')
        self.assertEqual(oFile.lines[5].line, '  a <= b - c')
        self.assertEqual(oFile.lines[6].line, '  a <= b - c')
        self.assertEqual(oFile.lines[7].line, '  a <= b - c')
        self.assertEqual(oFile.lines[8].line, '  a <= b - c')
        self.assertEqual(oFile.lines[9].line, '  a <= b / c')
        self.assertEqual(oFile.lines[10].line, '  a <= b / c')
        self.assertEqual(oFile.lines[11].line, '  a <= b / c')
        self.assertEqual(oFile.lines[12].line, '  a <= b / c')
        self.assertEqual(oFile.lines[13].line, '  a <= b * c')
        self.assertEqual(oFile.lines[14].line, '  a <= b * c')
        self.assertEqual(oFile.lines[15].line, '  a <= b * c')
        self.assertEqual(oFile.lines[16].line, '  a <= b * c')
        self.assertEqual(oFile.lines[17].line, '  a <= b ** c')
        self.assertEqual(oFile.lines[18].line, '  a <= b ** c')
        self.assertEqual(oFile.lines[19].line, '  a <= b ** c')
        self.assertEqual(oFile.lines[20].line, '  a <= b ** c')
        self.assertEqual(oFile.lines[21].line, '  a <= b ** c -- This**is fine')
        self.assertEqual(oFile.lines[22].line, '  a <= b ** c -- This**is fine')
        self.assertEqual(oFile.lines[23].line, '  a <= ) + (')
        self.assertEqual(oFile.lines[24].line, '  a <= ) + (')
        self.assertEqual(oFile.lines[25].line, '  a <= ) + (')
        self.assertEqual(oFile.lines[26].line, '  a <= ) + (')