Skip to content
Merged
6 changes: 6 additions & 0 deletions docs/configuring_whitespace_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ Rules Enforcing Whitespace
* `constant_010 <constant_rules.html#constant-010>`_
* `constant_100 <constant_rules.html#constant-100>`_
* `constant_101 <constant_rules.html#constant-101>`_
* `constrained_array_definition_100 <constrained_array_definition_rules.html#constrained-array-definition-100>`_
* `constrained_array_definition_101 <constrained_array_definition_rules.html#constrained-array-definition-101>`_
* `constrained_array_definition_102 <constrained_array_definition_rules.html#constrained-array-definition-102>`_
* `context_002 <context_rules.html#context-002>`_
* `context_017 <context_rules.html#context-017>`_
* `context_018 <context_rules.html#context-018>`_
Expand Down Expand Up @@ -274,6 +277,9 @@ Rules Enforcing Whitespace
* `type_006 <type_rules.html#type-006>`_
* `type_007 <type_rules.html#type-007>`_
* `type_100 <type_rules.html#type-100>`_
* `unbounded_array_definition_100 <unbounded_array_definition_rules.html#unbounded-array-definition-100>`_
* `unbounded_array_definition_101 <unbounded_array_definition_rules.html#unbounded-array-definition-101>`_
* `unbounded_array_definition_102 <unbounded_array_definition_rules.html#unbounded-array-definition-102>`_
* `variable_005 <variable_rules.html#variable-005>`_
* `variable_006 <variable_rules.html#variable-006>`_
* `variable_100 <variable_rules.html#variable-100>`_
Expand Down
65 changes: 65 additions & 0 deletions docs/constrained_array_definition_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,71 @@
Constrained Array Definition Rules
----------------------------------

constrained_array_definition_100
################################

|phase_2| |error| |whitespace|

This rule checks for whitespace after the **array** keyword.

|configuring_whitespace_rules_link|

**Violation**

.. code-block:: vhdl

type t_u_array is array (1 downto 0) of unsigned;
type t_u_array is array (1 downto 0) of unsigned;

**Fix**

.. code-block:: vhdl

type t_u_array is array(1 downto 0) of unsigned;
type t_u_array is array(1 downto 0) of unsigned;

constrained_array_definition_101
################################

|phase_2| |error| |whitespace|

This rule checks for a single space before the **of** keyword.

|configuring_whitespace_rules_link|

**Violation**

.. code-block:: vhdl

type t_u_array is array(1 downto 0) of unsigned;

**Fix**

.. code-block:: vhdl

type t_u_array is array(1 downto 0) of unsigned;

constrained_array_definition_102
################################

|phase_2| |error| |whitespace|

This rule checks for a single space after the **of** keyword.

|configuring_whitespace_rules_link|

**Violation**

.. code-block:: vhdl

type t_u_array is array(1 downto 0) of unsigned;

**Fix**

.. code-block:: vhdl

type t_u_array is array(1 downto 0) of unsigned;

constrained_array_definition_500
################################

Expand Down
6 changes: 6 additions & 0 deletions docs/rule_groups/whitespace_rule_group.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Rules Enforcing Whitespace Rule Group
* `constant_010 <../constant_rules.html#constant-010>`_
* `constant_100 <../constant_rules.html#constant-100>`_
* `constant_101 <../constant_rules.html#constant-101>`_
* `constrained_array_definition_100 <../constrained_array_definition_rules.html#constrained-array-definition-100>`_
* `constrained_array_definition_101 <../constrained_array_definition_rules.html#constrained-array-definition-101>`_
* `constrained_array_definition_102 <../constrained_array_definition_rules.html#constrained-array-definition-102>`_
* `context_002 <../context_rules.html#context-002>`_
* `context_017 <../context_rules.html#context-017>`_
* `context_018 <../context_rules.html#context-018>`_
Expand Down Expand Up @@ -171,6 +174,9 @@ Rules Enforcing Whitespace Rule Group
* `type_006 <../type_rules.html#type-006>`_
* `type_007 <../type_rules.html#type-007>`_
* `type_100 <../type_rules.html#type-100>`_
* `unbounded_array_definition_100 <../unbounded_array_definition_rules.html#unbounded-array-definition-100>`_
* `unbounded_array_definition_101 <../unbounded_array_definition_rules.html#unbounded-array-definition-101>`_
* `unbounded_array_definition_102 <../unbounded_array_definition_rules.html#unbounded-array-definition-102>`_
* `variable_005 <../variable_rules.html#variable-005>`_
* `variable_006 <../variable_rules.html#variable-006>`_
* `variable_100 <../variable_rules.html#variable-100>`_
Expand Down
65 changes: 65 additions & 0 deletions docs/unbounded_array_definition_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,71 @@
Unbounded Array Definition Rules
--------------------------------

unbounded_array_definition_100
##############################

|phase_2| |error| |whitespace|

This rule checks for whitespace after the **array** keyword.

|configuring_whitespace_rules_link|

**Violation**

.. code-block:: vhdl

type t_u_array_unconstrained is array(natural range <>) of unsigned;
type t_u_array_unconstrained is array (natural range <>) of unsigned;

**Fix**

.. code-block:: vhdl

type t_u_array_unconstrained is array(natural range <>) of unsigned;
type t_u_array_unconstrained is array(natural range <>) of unsigned;

unbounded_array_definition_101
##############################

|phase_2| |error| |whitespace|

This rule checks for a single space before the **of** keyword.

|configuring_whitespace_rules_link|

**Violation**

.. code-block:: vhdl

type t_u_array_unconstrained is array(natural range <>) of unsigned;

**Fix**

.. code-block:: vhdl

type t_u_array_unconstrained is array (natural range <>) of unsigned;

unbounded_array_definition_102
##############################

|phase_2| |error| |whitespace|

This rule checks for a single space after the **of** keyword.

|configuring_whitespace_rules_link|

**Violation**

.. code-block:: vhdl

type t_u_array_unconstrained is array(natural range <>) of unsigned;

**Fix**

.. code-block:: vhdl

type t_u_array_unconstrained is array (natural range <>) of unsigned;

unbounded_array_definition_500
##############################

Expand Down
14 changes: 14 additions & 0 deletions tests/constrained_array_definition/rule_100_test_input.fixed.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

architecture RTL of FIFO is

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 std_logic_vector(7 downto 0);
type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0);

type my_array is array(0 to 7) of std_logic_vector(7 downto 0);
type my_array is array(0 to 7) of std_logic_vector(7 downto 0);
type my_array is array(0 to 7) of std_logic_vector(7 downto 0);

begin

end architecture RTL;
14 changes: 14 additions & 0 deletions tests/constrained_array_definition/rule_100_test_input.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

architecture RTL of FIFO is

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 std_logic_vector(7 downto 0);
type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0);

type my_array is array (0 to 7) of std_logic_vector(7 downto 0);
type my_array is array (0 to 7) of std_logic_vector(7 downto 0);
type my_array is array(0 to 7) of std_logic_vector(7 downto 0);

begin

end architecture RTL;
12 changes: 12 additions & 0 deletions tests/constrained_array_definition/rule_101_test_input.fixed.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

architecture RTL of FIFO is

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 std_logic_vector(7 downto 0);

type my_array is array(0 to 7) of std_logic_vector(7 downto 0);
type my_array is array(0 to 7) of std_logic_vector(7 downto 0);

begin

end architecture RTL;
12 changes: 12 additions & 0 deletions tests/constrained_array_definition/rule_101_test_input.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

architecture RTL of FIFO is

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 std_logic_vector(7 downto 0);

type my_array is array(0 to 7) of std_logic_vector(7 downto 0);
type my_array is array(0 to 7) of std_logic_vector(7 downto 0);

begin

end architecture RTL;
12 changes: 12 additions & 0 deletions tests/constrained_array_definition/rule_102_test_input.fixed.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

architecture RTL of FIFO is

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 std_logic_vector(7 downto 0);

type my_array is array(0 to 7) of std_logic_vector(7 downto 0);
type my_array is array(0 to 7) of std_logic_vector(7 downto 0);

begin

end architecture RTL;
12 changes: 12 additions & 0 deletions tests/constrained_array_definition/rule_102_test_input.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

architecture RTL of FIFO is

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 std_logic_vector(7 downto 0);

type my_array is array(0 to 7) of std_logic_vector(7 downto 0);
type my_array is array(0 to 7) of std_logic_vector(7 downto 0);

begin

end architecture RTL;
48 changes: 48 additions & 0 deletions tests/constrained_array_definition/test_rule_100.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-

import os
import unittest

from tests import utils
from vsg import vhdlFile
from vsg.rules import constrained_array_definition

sTestDir = os.path.dirname(__file__)

lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd"))

dIndentMap = utils.read_indent_file()

lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected)


class test_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)
self.oFile.set_indent_map(dIndentMap)

def test_rule_100(self):
oRule = constrained_array_definition.rule_100()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "constrained_array_definition")
self.assertEqual(oRule.identifier, "100")

lExpected = [4, 5, 8, 9]

oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))

def test_fix_rule_100(self):
oRule = constrained_array_definition.rule_100()

oRule.fix(self.oFile)

lActual = self.oFile.get_lines()

self.assertEqual(lExpected, lActual)

oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])
48 changes: 48 additions & 0 deletions tests/constrained_array_definition/test_rule_101.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-

import os
import unittest

from tests import utils
from vsg import vhdlFile
from vsg.rules import constrained_array_definition

sTestDir = os.path.dirname(__file__)

lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_101_test_input.vhd"))

dIndentMap = utils.read_indent_file()

lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_101_test_input.fixed.vhd"), lExpected)


class test_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)
self.oFile.set_indent_map(dIndentMap)

def test_rule_101(self):
oRule = constrained_array_definition.rule_101()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "constrained_array_definition")
self.assertEqual(oRule.identifier, "101")

lExpected = [4, 7]

oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))

def test_fix_rule_101(self):
oRule = constrained_array_definition.rule_101()

oRule.fix(self.oFile)

lActual = self.oFile.get_lines()

self.assertEqual(lExpected, lActual)

oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])
Loading
Loading