Added rule procedure_call_400 to align multiline procedure calls. 1) Added tests 2) Added documentation 3) Added rule procedure_call_400
This commit is contained in:
parent
4d449e820c
commit
eb086accf8
|
|
@ -137,6 +137,29 @@ This rule checks the indent of the *procedure* name.
|
|||
|
||||
WR_EN(parameter);
|
||||
|
||||
procedure_call_400
|
||||
##################
|
||||
|
||||
|phase_5| |error| |alignment|
|
||||
|
||||
This rule checks the alignment of multiline procedure calls.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
connect_ports(port_1, port_2, port_3,
|
||||
port_4, port_5,
|
||||
port_6, port_7);
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
connect_ports(port_1, port_2, port_3,
|
||||
port_4, port_5,
|
||||
port_6, port_7);
|
||||
|
||||
procedure_call_500
|
||||
##################
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ from .rule_300 import rule_300
|
|||
from .rule_301 import rule_301
|
||||
from .rule_302 import rule_302
|
||||
|
||||
from .rule_400 import rule_400
|
||||
|
||||
from .rule_500 import rule_500
|
||||
from .rule_501 import rule_501
|
||||
#
|
||||
#from .rule_600 import rule_600
|
||||
#from .rule_601 import rule_601
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
from vsg.rules import multiline_alignment_between_tokens as Rule
|
||||
|
||||
from vsg import token
|
||||
|
||||
lTokenPairs = []
|
||||
lTokenPairs.append([token.procedure_call.open_parenthesis, token.procedure_call.close_parenthesis])
|
||||
|
||||
|
||||
class rule_400(Rule):
|
||||
'''
|
||||
This rule checks the alignment of multiline procedure calls.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
connect_ports(port_1, port_2, port_3,
|
||||
port_4, port_5,
|
||||
port_6, port_7);
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
connect_ports(port_1, port_2, port_3,
|
||||
port_4, port_5,
|
||||
port_6, port_7);
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
Rule.__init__(self, 'procedure_call', '400', lTokenPairs)
|
||||
self.phase = 5
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
architecture rtl of fifo is
|
||||
|
||||
begin
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
process begin
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
end process;
|
||||
|
||||
-- Violations below
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
process begin
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
architecture rtl of fifo is
|
||||
|
||||
begin
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
process begin
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
end process;
|
||||
|
||||
-- Violations below
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
process begin
|
||||
|
||||
procedure_call(first, second(2),
|
||||
third(func_call(4, 5, 6)), fourth(7),
|
||||
fifth(8));
|
||||
|
||||
bare_procedure_call;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from vsg.rules import procedure_call
|
||||
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_400_test_input.vhd'))
|
||||
|
||||
lExpected = []
|
||||
lExpected.append('')
|
||||
utils.read_file(os.path.join(sTestDir, 'rule_400_test_input.fixed.vhd'), lExpected, False)
|
||||
|
||||
|
||||
class test_procedure_call_rule(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
||||
def test_rule_400(self):
|
||||
oRule = procedure_call.rule_400()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'procedure_call')
|
||||
self.assertEqual(oRule.identifier, '400')
|
||||
self.assertEqual(oRule.groups, ['alignment'])
|
||||
|
||||
lExpected = [25,26, 33, 34]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_400(self):
|
||||
oRule = procedure_call.rule_400()
|
||||
|
||||
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