Skip to content

Commit ce4e5c6

Browse files
committed
Issue#1511: Added tests for new rule to enforce position of assignment operator in variable declarations.
1 parent f23cd2a commit ce4e5c6

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
architecture RTL of FIFO is
3+
4+
begin
5+
6+
my_proc : process
7+
8+
variable c_width : integer;
9+
10+
variable c_width : integer := 16;
11+
12+
variable c_depth : integer :=
13+
512;
14+
15+
variable AVMM_MASTER_NULL : avmm_master_t := (
16+
(others => '0'),
17+
(others => '0'),
18+
'0',
19+
'0'
20+
);
21+
22+
--! Test stimulus
23+
CONSTANT c_stimulus : t_stimulus_array :=
24+
(
25+
(
26+
name => "Hold in reset ",
27+
clk_in => "0101010101010101",
28+
rst_in => "1111111111111111",
29+
cnt_en_in => "0000000000000000",
30+
cnt_out => "0000000000000000"
31+
),
32+
(
33+
name => "Not enabled ",
34+
clk_in => "0101010101010101",
35+
rst_in => "0000000000000000",
36+
cnt_en_in => "0000000000000000",
37+
cnt_out => "0000000000000000"
38+
)
39+
);
40+
41+
begin
42+
43+
end process;
44+
45+
end architecture RTL;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
architecture RTL of FIFO is
3+
4+
begin
5+
6+
my_proc : process
7+
8+
variable c_width : integer;
9+
10+
variable c_width : integer := 16;
11+
12+
variable c_depth : integer
13+
:= 512;
14+
15+
variable AVMM_MASTER_NULL : avmm_master_t := (
16+
(others => '0'),
17+
(others => '0'),
18+
'0',
19+
'0'
20+
);
21+
22+
--! Test stimulus
23+
CONSTANT c_stimulus : t_stimulus_array :=
24+
(
25+
(
26+
name => "Hold in reset ",
27+
clk_in => "0101010101010101",
28+
rst_in => "1111111111111111",
29+
cnt_en_in => "0000000000000000",
30+
cnt_out => "0000000000000000"
31+
),
32+
(
33+
name => "Not enabled ",
34+
clk_in => "0101010101010101",
35+
rst_in => "0000000000000000",
36+
cnt_en_in => "0000000000000000",
37+
cnt_out => "0000000000000000"
38+
)
39+
);
40+
41+
begin
42+
43+
end process;
44+
45+
end architecture RTL;

tests/variable/test_rule_018.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import os
4+
import unittest
5+
6+
from tests import utils
7+
from vsg import vhdlFile
8+
from vsg.rules import variable
9+
10+
sTestDir = os.path.dirname(__file__)
11+
12+
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_018_test_input.vhd"))
13+
14+
lExpected = []
15+
lExpected.append("")
16+
utils.read_file(os.path.join(sTestDir, "rule_018_test_input.fixed.vhd"), lExpected)
17+
18+
19+
class test_rule(unittest.TestCase):
20+
def setUp(self):
21+
self.oFile = vhdlFile.vhdlFile(lFile)
22+
self.assertIsNone(eError)
23+
24+
def test_rule_018(self):
25+
oRule = variable.rule_018()
26+
self.assertTrue(oRule)
27+
self.assertEqual(oRule.name, "variable")
28+
self.assertEqual(oRule.identifier, "018")
29+
self.assertEqual(oRule.groups, ["structure"])
30+
31+
lExpected = [12]
32+
33+
oRule.analyze(self.oFile)
34+
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
35+
36+
def test_fix_rule_018(self):
37+
oRule = variable.rule_018()
38+
39+
oRule.fix(self.oFile)
40+
41+
lActual = self.oFile.get_lines()
42+
43+
self.assertEqual(lExpected, lActual)
44+
45+
oRule.analyze(self.oFile)
46+
self.assertEqual(oRule.violations, [])

0 commit comments

Comments
 (0)