Skip to content

Commit 84f62f3

Browse files
committed
Issue#1490: Added tests for whitespace rules 102 and 103.
1 parent 4b56079 commit 84f62f3

File tree

6 files changed

+168
-0
lines changed

6 files changed

+168
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
entity b is
3+
port (
4+
c : in std_logic_vector(7 downto 0)
5+
);
6+
end entity b;
7+
8+
architecture a of b is
9+
10+
type my_array2 is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
11+
12+
subtype my_array3 is my_array2(open)(7 downto 0);
13+
14+
subtype my_array4 is natural range 0 to 7;
15+
16+
begin
17+
18+
x <= y(7 downto 0);
19+
20+
end architecture a;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
entity b is
3+
port (
4+
c : in std_logic_vector(7 downto 0)
5+
);
6+
end entity b;
7+
8+
architecture a of b is
9+
10+
type my_array2 is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
11+
12+
subtype my_array3 is my_array2(open)(7 downto 0);
13+
14+
subtype my_array4 is natural range 0 to 7;
15+
16+
begin
17+
18+
x <= y(7 downto 0);
19+
20+
end architecture a;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
entity b is
3+
port (
4+
c : in std_logic_vector(7 downto 0)
5+
);
6+
end entity b;
7+
8+
architecture a of b is
9+
10+
type my_array2 is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
11+
12+
subtype my_array3 is my_array2(open)(7 downto 0);
13+
14+
subtype my_array4 is natural range 0 to 7;
15+
16+
begin
17+
18+
x <= y(7 downto 0);
19+
20+
end architecture a;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
entity b is
3+
port (
4+
c : in std_logic_vector(7 downto 0)
5+
);
6+
end entity b;
7+
8+
architecture a of b is
9+
10+
type my_array2 is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
11+
12+
subtype my_array3 is my_array2(open)(7 downto 0);
13+
14+
subtype my_array4 is natural range 0 to 7;
15+
16+
begin
17+
18+
x <= y(7 downto 0);
19+
20+
end architecture a;

tests/whitespace/test_rule_102.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 whitespace
9+
10+
sTestDir = os.path.dirname(__file__)
11+
12+
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_102_test_input.vhd"))
13+
lExpected = []
14+
lExpected.append("")
15+
utils.read_file(os.path.join(sTestDir, "rule_102_test_input.fixed.vhd"), lExpected)
16+
17+
18+
class test_whitespace_rule(unittest.TestCase):
19+
def setUp(self):
20+
self.oFile = vhdlFile.vhdlFile(lFile)
21+
self.assertIsNone(eError)
22+
23+
def test_rule_102(self):
24+
oRule = whitespace.rule_102()
25+
self.assertTrue(oRule)
26+
self.assertEqual(oRule.name, "whitespace")
27+
self.assertEqual(oRule.identifier, "102")
28+
29+
lExpected = [4, 10, 10, 12, 14, 18]
30+
31+
oRule.analyze(self.oFile)
32+
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
33+
34+
def test_fix_rule_102(self):
35+
oRule = whitespace.rule_102()
36+
37+
oRule.fix(self.oFile)
38+
39+
lActual = self.oFile.get_lines()
40+
41+
self.assertEqual(lExpected, lActual)
42+
43+
oRule.analyze(self.oFile)
44+
self.assertEqual(oRule.violations, [])

tests/whitespace/test_rule_103.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 whitespace
9+
10+
sTestDir = os.path.dirname(__file__)
11+
12+
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_103_test_input.vhd"))
13+
lExpected = []
14+
lExpected.append("")
15+
utils.read_file(os.path.join(sTestDir, "rule_103_test_input.fixed.vhd"), lExpected)
16+
17+
18+
class test_whitespace_rule(unittest.TestCase):
19+
def setUp(self):
20+
self.oFile = vhdlFile.vhdlFile(lFile)
21+
self.assertIsNone(eError)
22+
23+
def test_rule_103(self):
24+
oRule = whitespace.rule_103()
25+
self.assertTrue(oRule)
26+
self.assertEqual(oRule.name, "whitespace")
27+
self.assertEqual(oRule.identifier, "103")
28+
29+
lExpected = [4, 10, 10, 12, 14, 18]
30+
31+
oRule.analyze(self.oFile)
32+
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
33+
34+
def test_fix_rule_103(self):
35+
oRule = whitespace.rule_103()
36+
37+
oRule.fix(self.oFile)
38+
39+
lActual = self.oFile.get_lines()
40+
41+
self.assertEqual(lExpected, lActual)
42+
43+
oRule.analyze(self.oFile)
44+
self.assertEqual(oRule.violations, [])

0 commit comments

Comments
 (0)