Updates for issue #469

Fixed issue with rules instantiation_025 and instantiation_026 firing on lines in which the parenthesis was on the same line.

  1)  Updated tests to expose issue
  2)  Updated base rule to address issue
This commit is contained in:
Jeremiah Leary 2020-11-22 19:53:54 -06:00
parent 476a5f0729
commit 6a229f2640
7 changed files with 52 additions and 3 deletions

View File

@ -40,7 +40,8 @@ class move_token_next_to_another_token(rule_item.Rule):
lToi = oFile.get_tokens_bounded_by(self.anchor_token, self.token_to_move)
for oToi in lToi:
lTokens = oToi.get_tokens()
if not utils.are_next_consecutive_token_types([self.anchor_token, parser.whitespace, self.token_to_move], 0, lTokens):
if not utils.are_next_consecutive_token_types([self.anchor_token, parser.whitespace, self.token_to_move], 0, lTokens) and \
not utils.are_next_consecutive_token_types([self.anchor_token, self.token_to_move], 0, lTokens):
self.add_violation(violation.New(oToi.get_line_number(), oToi, self.solution))

View File

@ -15,6 +15,18 @@ begin
PORT_3 => w_port_3
);
U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map(
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);
-- Violations below
U_INST1 : INST1

View File

@ -15,6 +15,18 @@ begin
PORT_3 => w_port_3
);
U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map(
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);
-- Violations below
U_INST1 : INST1

View File

@ -15,6 +15,18 @@ begin
PORT_3 => w_port_3
);
U_INST1 : INST1
generic map(
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);
-- Violations below
U_INST1 : INST1

View File

@ -15,6 +15,18 @@ begin
PORT_3 => w_port_3
);
U_INST1 : INST1
generic map(
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);
-- Violations below
U_INST1 : INST1

View File

@ -26,7 +26,7 @@ class test_instantiation_rule(unittest.TestCase):
self.assertEqual(oRule.name, 'instantiation')
self.assertEqual(oRule.identifier, '025')
lExpected = [26]
lExpected = [38]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))

View File

@ -26,7 +26,7 @@ class test_instantiation_rule(unittest.TestCase):
self.assertEqual(oRule.name, 'instantiation')
self.assertEqual(oRule.identifier, '026')
lExpected = [21]
lExpected = [33]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))