Esempio n. 1
0
    def test_rule_001_with_uppercase(self):
        oRule = ranges.rule_001()
        oRule.case = 'upper'
        lExpected = []
        dViolation = utils.add_violation(5, )
        dViolation['words_to_fix'] = {'downto'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(9, )
        dViolation['words_to_fix'] = {'downto'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(17)
        dViolation['words_to_fix'] = {'downTo'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(21)
        dViolation['words_to_fix'] = {'Downto'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(29)
        dViolation['words_to_fix'] = {'downto'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(33)
        dViolation['words_to_fix'] = {'dOWnto'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(34)
        dViolation['words_to_fix'] = {'downto'}
        lExpected.append(dViolation)

        oRule.analyze(oFile)
        self.assertEqual(oRule.violations, lExpected)
 def test_rule_001_with_uppercase(self):
     oRule = ranges.rule_001()
     oRule.case = 'upper'
     dExpected = [{
         'line_number': 5,
         'words_to_fix': {'downto'}
     }, {
         'line_number': 9,
         'words_to_fix': {'downto'}
     }, {
         'line_number': 17,
         'words_to_fix': {'downTo'}
     }, {
         'line_number': 21,
         'words_to_fix': {'Downto'}
     }, {
         'line_number': 29,
         'words_to_fix': {'downto'}
     }, {
         'line_number': 33,
         'words_to_fix': {'dOWnto'}
     }, {
         'line_number': 34,
         'words_to_fix': {'downto'}
     }]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)
Esempio n. 3
0
    def test_rule_001_with_uppercase(self):
        oRule = ranges.rule_001()
        oRule.case = 'upper'
        dExpected = []
        oRule.fix(self.oFile)
        self.assertEqual(self.oFile.lines[5].line,
                         '    G_GENERIC1 : std_logic_vector(3 DOWNTO 0);')
        self.assertEqual(
            self.oFile.lines[9].line,
            '    P_PORT1 : std_logic_vector(15 DOWNTO 6); -- DOWNTO')
        self.assertEqual(self.oFile.lines[17].line,
                         '    G_GENERIC1 : std_logic_vector(3 DOWNTO 0);')
        self.assertEqual(self.oFile.lines[21].line,
                         '    P_PORT1 : std_logic_vector(15 DOWNTO 6);')
        self.assertEqual(
            self.oFile.lines[29].line,
            '  constant c_const2 : std_logic_vector(3 DOWNTO 0);')
        self.assertEqual(self.oFile.lines[33].line,
                         '  signal w_sig1 : std_logic_vector(50 DOWNTO 45);')
        self.assertEqual(self.oFile.lines[34].line,
                         '  signal w_sig2 : std_logic_vector(50 DOWNTO 45);')

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

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
 def test_rule_001_with_default(self):
     oRule = ranges.rule_001()
     self.assertTrue(oRule)
     self.assertEqual(oRule.name, 'range')
     self.assertEqual(oRule.identifier, '001')
     dExpected = [17,21,28,33]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)
Esempio n. 5
0
    def test_fix_rule_001_lower(self):
        oRule = ranges.rule_001()

        oRule.fix(self.oFile)

        lActual = self.oFile.get_lines()

        self.assertEqual(lExpected_lower, lActual)

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, [])
Esempio n. 6
0
    def test_rule_001_upper(self):
        oRule = ranges.rule_001()
        oRule.case = 'upper'
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'range')
        self.assertEqual(oRule.identifier, '001')

        lExpected = [5, 9, 17, 21, 29, 33, 34]
        oRule.analyze(self.oFile)
        self.assertEqual(
            lExpected,
            utils.extract_violation_lines_from_violation_object(
                oRule.violations))
Esempio n. 7
0
    def test_rule_001_lower(self):
        oRule = ranges.rule_001()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'range')
        self.assertEqual(oRule.identifier, '001')

        lExpected = [17, 21, 28, 33]

        oRule.analyze(self.oFile)
        self.assertEqual(
            lExpected,
            utils.extract_violation_lines_from_violation_object(
                oRule.violations))
Esempio n. 8
0
    def test_rule_001_with_lowercase(self):
        oRule = ranges.rule_001()
        dExpected = []
        oRule.fix(self.oFile)
        self.assertEqual(self.oFile.lines[17].line,
                         '    G_GENERIC1 : std_logic_vector(3 downto 0);')
        self.assertEqual(self.oFile.lines[21].line,
                         '    P_PORT1 : std_logic_vector(15 downto 6);')
        self.assertEqual(
            self.oFile.lines[28].line,
            '  constant c_const1 : std_logic_vector(3 downto 0);  -- downto')
        self.assertEqual(self.oFile.lines[33].line,
                         '  signal w_sig1 : std_logic_vector(50 downto 45);')

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

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
 def test_rule_001_with_default(self):
     oRule = ranges.rule_001()
     self.assertTrue(oRule)
     self.assertEqual(oRule.name, 'range')
     self.assertEqual(oRule.identifier, '001')
     dExpected = [{
         'line_number': 17,
         'words_to_fix': {'downTo'}
     }, {
         'line_number': 21,
         'words_to_fix': {'Downto'}
     }, {
         'line_number': 28,
         'words_to_fix': {'DOWNTO'}
     }, {
         'line_number': 33,
         'words_to_fix': {'dOWnto'}
     }]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)
Esempio n. 10
0
    def test_rule_001_with_default(self):
        oRule = ranges.rule_001()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'range')
        self.assertEqual(oRule.identifier, '001')
        lExpected = []
        dViolation = utils.add_violation(17)
        dViolation['words_to_fix'] = {'downTo'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(21)
        dViolation['words_to_fix'] = {'Downto'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(28)
        dViolation['words_to_fix'] = {'DOWNTO'}
        lExpected.append(dViolation)

        dViolation = utils.add_violation(33)
        dViolation['words_to_fix'] = {'dOWnto'}
        lExpected.append(dViolation)

        oRule.analyze(oFile)
        self.assertEqual(oRule.violations, lExpected)
Esempio n. 11
0
 def test_rule_001_with_uppercase(self):
     oRule = ranges.rule_001()
     oRule.case = 'upper'
     dExpected = [5,9,17,21,29,33,34]
     oRule.analyze(oFile)
     self.assertEqual(oRule.violations, dExpected)