create function_300 tests
This commit is contained in:
parent
eabfaedd2a
commit
6a3d1c8562
|
|
@ -432,3 +432,33 @@ Refer to the section `Configuring Uppercase and Lowercase Rules <configuring.htm
|
|||
.. code-block:: vhdl
|
||||
|
||||
function overflow (a: integer) return integer is
|
||||
|
||||
function_300
|
||||
############
|
||||
|
||||
|phase_4| |error|
|
||||
|
||||
This rule checks the indent of the closing parenthesis if it is on it's own line.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
function func_1 (a : integer; b : integer;
|
||||
c : unsigned(3 downto 0);
|
||||
d : std_logic_vector(7 downto 0);
|
||||
e : std_logic
|
||||
) return integer is
|
||||
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
function func_1 (a : integer; b : integer;
|
||||
c : unsigned(3 downto 0);
|
||||
d : std_logic_vector(7 downto 0);
|
||||
e : std_logic
|
||||
) return integer is
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
pure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
impure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
pure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
impure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
pure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
impure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
pure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
impure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
pure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
impure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
pure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
impure function func_name (
|
||||
a : integer;
|
||||
constant b : integer;
|
||||
signal c : std_logic;
|
||||
variable v : std_logic;
|
||||
file f : std_logic
|
||||
) return integer is
|
||||
begin
|
||||
return 0;
|
||||
end function func_name;
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from vsg.rules import function
|
||||
from vsg import vhdlFile
|
||||
from vsg.tests import utils
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError =vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir,'rule_300_test_input.vhd'))
|
||||
|
||||
dIndentMap = utils.read_indent_file()
|
||||
|
||||
lExpected = []
|
||||
lExpected.append('')
|
||||
utils.read_file(os.path.join(sTestDir, 'rule_300_test_input.fixed.vhd'), lExpected)
|
||||
|
||||
|
||||
class test_function_rule(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
self.oFile.set_indent_map(dIndentMap)
|
||||
|
||||
def test_rule_300(self):
|
||||
oRule = function.rule_300()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'function')
|
||||
self.assertEqual(oRule.identifier, '300')
|
||||
|
||||
lExpected = [18, 27]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_300(self):
|
||||
oRule = function.rule_300()
|
||||
|
||||
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