def test_fix_rule_007_w_default_options(self): oRule = concurrent.rule_007() dExpected = [] oRule.fix(self.oFile) self.assertEqual(self.oFile.lines[10].line, ' O_FOO <= w_foo when (w_foo_en = \'1\') else') self.assertFalse(self.oFile.lines[10].isEndConcurrent) self.assertEqual(self.oFile.lines[11].line, ' \'Z\';') self.assertTrue(self.oFile.lines[11].insideConcurrent) self.assertTrue(self.oFile.lines[11].isEndConcurrent) self.assertEqual(self.oFile.lines[12].line, ' O_BAR <= w_bar when (w_bar_en = \'0\') else') self.assertFalse(self.oFile.lines[12].isEndConcurrent) self.assertEqual(self.oFile.lines[13].line, ' \'1\';') self.assertTrue(self.oFile.lines[13].insideConcurrent) self.assertTrue(self.oFile.lines[13].isEndConcurrent) self.assertEqual(self.oFile.lines[18].line, ' O_FOO <= w_foo when (w_foo_en = \'1\') else') self.assertFalse(self.oFile.lines[18].isEndConcurrent) self.assertEqual(self.oFile.lines[19].line, ' w_bar when (w_bar_en = \'1\') else') self.assertTrue(self.oFile.lines[19].insideConcurrent) self.assertFalse(self.oFile.lines[19].isEndConcurrent) self.assertEqual(self.oFile.lines[20].line, ' \'Z\';') self.assertTrue(self.oFile.lines[20].insideConcurrent) self.assertTrue(self.oFile.lines[20].isEndConcurrent) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, dExpected)
def test_fix_rule_007(self): oRule = concurrent.rule_007() dExpected = [] oRule.fix(oFile) oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected) self.assertEqual(oFile.lines[34].line, ' a <= b; -- this else should not trigger')
def test_rule_007(self): oRule = concurrent.rule_007() self.assertTrue(oRule) self.assertEqual(oRule.name, 'concurrent') self.assertEqual(oRule.identifier, '007') dExpected = [44,48] oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected)
def test_fix_rule_007_w_allow_single_line_false(self): oRule = concurrent.rule_007() oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected_false, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
def test_rule_007_w_allow_single_line_false(self): oRule = concurrent.rule_007() self.assertTrue(oRule) self.assertEqual(oRule.name, 'concurrent') self.assertEqual(oRule.identifier, '007') lExpected = [8, 18, 18, 18, 20, 20, 21, 23, 24, 24] oRule.analyze(self.oFile) self.assertEqual( lExpected, utils.extract_violation_lines_from_violation_object( oRule.violations))
def test_rule_007_w_allow_single_line_option_enabled(self): oRule = concurrent.rule_007() oRule.allow_single_line = True lExpected = [] dViolation = utils.add_violation(16) dViolation['slice_index'] = [43, 76] lExpected.append(dViolation) dViolation = utils.add_violation(17) dViolation['slice_index'] = [43, 76] lExpected.append(dViolation) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, lExpected)
def test_rule_007(self): oRule = concurrent.rule_007() self.assertTrue(oRule) self.assertEqual(oRule.name, 'concurrent') self.assertEqual(oRule.identifier, '007') lExpected = [] dViolation = utils.add_violation(44) dViolation['slice_index'] = [26] lExpected.append(dViolation) dViolation = utils.add_violation(48) dViolation['slice_index'] = [26] lExpected.append(dViolation) oRule.analyze(oFile) self.assertEqual(oRule.violations, lExpected)
def test_fix_rule_007_w_single_line_option_enabled(self): oRule = concurrent.rule_007() oRule.allow_single_line = True dExpected = [] oRule.fix(self.oFile) self.assertEqual(self.oFile.lines[16].line, ' O_FOO <= w_foo when (w_foo_en = \'1\') else') self.assertFalse(self.oFile.lines[16].isEndConcurrent) self.assertEqual(self.oFile.lines[17].line, ' w_bar when (w_bar_en = \'1\') else') self.assertTrue(self.oFile.lines[17].insideConcurrent) self.assertFalse(self.oFile.lines[17].isEndConcurrent) self.assertEqual(self.oFile.lines[18].line, ' \'Z\';') self.assertTrue(self.oFile.lines[18].insideConcurrent) self.assertTrue(self.oFile.lines[18].isEndConcurrent) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, dExpected)
def test_fix_rule_007(self): oRule = concurrent.rule_007() dExpected = [] oRule.fix(self.oFile) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, dExpected) self.assertEqual(self.oFile.lines[34].line, ' label : a <= b; -- this else should not trigger') self.assertEqual(self.oFile.lines[49].line, ' a <= b when g = \'1\' else') self.assertFalse(self.oFile.lines[49].hasComment) self.assertFalse(self.oFile.lines[49].hasInlineComment) self.assertEqual(self.oFile.lines[49].commentColumn, None) self.assertFalse(self.oFile.lines[49].isEndConcurrent) self.assertTrue(self.oFile.lines[49].isConcurrentBegin) self.assertEqual(self.oFile.lines[50].line, ' \'1\'; -- Not an error') self.assertTrue(self.oFile.lines[50].hasComment) self.assertTrue(self.oFile.lines[50].hasInlineComment) self.assertEqual(self.oFile.lines[50].commentColumn, 6) self.assertTrue(self.oFile.lines[50].isEndConcurrent) self.assertFalse(self.oFile.lines[50].isConcurrentBegin)
def test_rule_007_w_default_options(self): oRule = concurrent.rule_007() self.assertTrue(oRule) self.assertEqual(oRule.name, 'concurrent') self.assertEqual(oRule.identifier, '007') lExpected = [] dViolation = utils.add_violation(10) dViolation['slice_index'] = [43] lExpected.append(dViolation) dViolation = utils.add_violation(11) dViolation['slice_index'] = [43] lExpected.append(dViolation) dViolation = utils.add_violation(16) dViolation['slice_index'] = [43, 76] lExpected.append(dViolation) dViolation = utils.add_violation(17) dViolation['slice_index'] = [43, 76] lExpected.append(dViolation) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, lExpected)
def test_fix_rule_008(self): oRule = concurrent.rule_007() dExpected = [] oRule.fix(oFile) oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected)