#1491: Added tests for new rules.
This commit is contained in:
parent
fceac27841
commit
e866be03e8
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import index_subtype_definition
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd"))
|
||||
|
||||
lExpected = []
|
||||
lExpected.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected)
|
||||
|
||||
|
||||
class test_index_subtype_definition_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
||||
def test_rule_100(self):
|
||||
oRule = index_subtype_definition.rule_100()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "index_subtype_definition")
|
||||
self.assertEqual(oRule.identifier, "100")
|
||||
|
||||
lExpected = [10]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_100(self):
|
||||
oRule = index_subtype_definition.rule_100()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import index_subtype_definition
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_101_test_input.vhd"))
|
||||
|
||||
lExpected = []
|
||||
lExpected.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_101_test_input.fixed.vhd"), lExpected)
|
||||
|
||||
|
||||
class test_index_subtype_definition_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
||||
def test_rule_101(self):
|
||||
oRule = index_subtype_definition.rule_101()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "index_subtype_definition")
|
||||
self.assertEqual(oRule.identifier, "101")
|
||||
|
||||
lExpected = [10]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_101(self):
|
||||
oRule = index_subtype_definition.rule_101()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
-- Passing
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
-- Violation below
|
||||
|
||||
type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0);
|
||||
type my_array is array (natural range 0 to 7) of integer;
|
||||
subtype my_array is natural range 7 downto 0;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import range_constraint
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd"))
|
||||
|
||||
lExpected = []
|
||||
lExpected.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected)
|
||||
|
||||
|
||||
class test_range_constraint_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
||||
def test_rule_100(self):
|
||||
oRule = range_constraint.rule_100()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "range_constraint")
|
||||
self.assertEqual(oRule.identifier, "100")
|
||||
|
||||
lExpected = [12, 13, 14]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_100(self):
|
||||
oRule = range_constraint.rule_100()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import range_constraint
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_101_test_input.vhd"))
|
||||
|
||||
lExpected = []
|
||||
lExpected.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_101_test_input.fixed.vhd"), lExpected)
|
||||
|
||||
|
||||
class test_index_subtype_definition_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
||||
def test_rule_101(self):
|
||||
oRule = range_constraint.rule_101()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "range_constraint")
|
||||
self.assertEqual(oRule.identifier, "101")
|
||||
|
||||
lExpected = [12, 13, 14]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_101(self):
|
||||
oRule = range_constraint.rule_101()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
Loading…
Reference in New Issue