Example #1
0
    def test_rule_002_with_uppercase(self):
        oRule = ranges.rule_002()
        oRule.case = 'upper'
        dExpected = []
        oRule.fix(self.oFile)
        self.assertEqual(self.oFile.lines[6].line,
                         '    G_GENERIC2 : std_logic_vector(0 TO 256)')
        self.assertEqual(self.oFile.lines[10].line,
                         '    P_PORT2 : std_logic_vector(56 TO 132)')
        self.assertEqual(self.oFile.lines[22].line,
                         '    P_PORT2 : std_logic_vector(56 TO 132)')
        self.assertEqual(
            self.oFile.lines[30].line,
            '  constant c_const3 : std_logic_vector(345 TO 670);')
        self.assertEqual(
            self.oFile.lines[31].line,
            '  constant c_const4 : std_logic_vector(345 TO 670);')
        self.assertEqual(self.oFile.lines[36].line,
                         '  signal w_sig4 : std_logic_vector(46 TO 345);')

        self.assertEqual('Change "to" keyword to uppercase.',
                         oRule._get_solution(0))

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
Example #2
0
    def test_rule_002_with_uppercase(self):
        oRule = ranges.rule_002()
        oRule.case = 'upper'
        lExpected = []
        dViolation = utils.add_violation(6, )
        dViolation['words_to_fix'] = {'to'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(10)
        dViolation['words_to_fix'] = {'to'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(22)
        dViolation['words_to_fix'] = {'tO'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(30)
        dViolation['words_to_fix'] = {'To'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(31)
        dViolation['words_to_fix'] = {'to'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(36)
        dViolation['words_to_fix'] = {'to'}
        lExpected.append(dViolation)

        oRule.analyze(oFile)
        self.assertEqual(oRule.violations, lExpected)
 def test_rule_002_with_default(self):
     oRule = ranges.rule_002()
     self.assertTrue(oRule)
     self.assertEqual(oRule.name, 'range')
     self.assertEqual(oRule.identifier, '002')
     dExpected = [18,22,30,35]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)
    def test_fix_rule_002_lower(self):
        oRule = ranges.rule_002()

        oRule.fix(self.oFile)

        lActual = self.oFile.get_lines()

        self.assertEqual(lExpected_lower, lActual)

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, [])
    def test_rule_002_upper(self):
        oRule = ranges.rule_002()
        oRule.case = 'upper'
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'range')
        self.assertEqual(oRule.identifier, '002')

        lExpected = [6, 10, 22, 30, 31, 36]
        oRule.analyze(self.oFile)
        self.assertEqual(
            lExpected,
            utils.extract_violation_lines_from_violation_object(
                oRule.violations))
    def test_rule_002_with_lowercase(self):
        oRule = ranges.rule_002()
        dExpected = []
        oRule.fix(self.oFile)
        self.assertEqual(self.oFile.lines[18].line,
                         '    G_GENERIC2 : std_logic_vector(0 to 256)')
        self.assertEqual(self.oFile.lines[22].line,
                         '    P_PORT2 : std_logic_vector(56 to 132)')
        self.assertEqual(
            self.oFile.lines[30].line,
            '  constant c_const3 : std_logic_vector(345 to 670);')
        self.assertEqual(self.oFile.lines[35].line,
                         '  signal w_sig3 : std_logic_vector(46 to 345);')

        self.assertEqual('Change "to" keyword to lowercase.',
                         oRule._get_solution(0))

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
 def test_rule_002_with_default(self):
     oRule = ranges.rule_002()
     self.assertTrue(oRule)
     self.assertEqual(oRule.name, 'range')
     self.assertEqual(oRule.identifier, '002')
     dExpected = [{
         'line_number': 18,
         'words_to_fix': {'TO'}
     }, {
         'line_number': 22,
         'words_to_fix': {'tO'}
     }, {
         'line_number': 30,
         'words_to_fix': {'To'}
     }, {
         'line_number': 35,
         'words_to_fix': {'TO'}
     }]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)
 def test_rule_002_with_uppercase(self):
     oRule = ranges.rule_002()
     oRule.case = 'upper'
     dExpected = [{
         'line_number': 6,
         'words_to_fix': {'to'}
     }, {
         'line_number': 10,
         'words_to_fix': {'to'}
     }, {
         'line_number': 22,
         'words_to_fix': {'tO'}
     }, {
         'line_number': 30,
         'words_to_fix': {'To'}
     }, {
         'line_number': 31,
         'words_to_fix': {'to'}
     }, {
         'line_number': 36,
         'words_to_fix': {'to'}
     }]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)
Example #9
0
    def test_rule_002_with_default(self):
        oRule = ranges.rule_002()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'range')
        self.assertEqual(oRule.identifier, '002')
        lExpected = []
        dViolation = utils.add_violation(18)
        dViolation['words_to_fix'] = {'TO'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(22)
        dViolation['words_to_fix'] = {'tO'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(30)
        dViolation['words_to_fix'] = {'To'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(35)
        dViolation['words_to_fix'] = {'TO'}
        lExpected.append(dViolation)

        oRule.analyze(oFile)
        self.assertEqual(oRule.violations, lExpected)
 def test_rule_002_with_uppercase(self):
     oRule = ranges.rule_002()
     oRule.case = 'upper'
     dExpected = [6,10,22,30,31,36]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)