Merge branch 'jeremiah-c-leary:master' into issue-1322
This commit is contained in:
commit
5a8a7ceedf
|
|
@ -0,0 +1,25 @@
|
|||
.. include:: includes.rst
|
||||
|
||||
Aggregate Rules
|
||||
---------------
|
||||
|
||||
aggregate_500
|
||||
#############
|
||||
|
||||
|phase_6| |error| |case| |case_keyword|
|
||||
|
||||
This rule checks the *others* keyword in aggregates has proper case.
|
||||
|
||||
|configuring_uppercase_and_lowercase_rules_link|
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
signal counter : t_counter := (OTHERS => '1');
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
signal counter : t_counter := (others => '1');
|
||||
|
|
@ -533,6 +533,28 @@ The default style is :code:`allow_comment`.
|
|||
-- Comment
|
||||
when 4 =>
|
||||
|
||||
case_300
|
||||
########
|
||||
|
||||
|phase_4| |error| |indent|
|
||||
|
||||
This rule checks the indentation of the label.
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
case_label : case data is
|
||||
|
||||
end case;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
case_label : case data is
|
||||
|
||||
end case;
|
||||
|
||||
case_500
|
||||
########
|
||||
|
||||
|
|
|
|||
|
|
@ -221,6 +221,8 @@ For example, if you want to uppercase everything except the entity name, you cou
|
|||
Rules Enforcing Case
|
||||
####################
|
||||
|
||||
* `aggregate_500 <aggregate_rules.html#aggregate-500>`_
|
||||
|
||||
* `alias_declaration_500 <alias_declaration_rules.html#alias-declaration-500>`_
|
||||
* `alias_declaration_501 <alias_declaration_rules.html#alias-declaration-501>`_
|
||||
* `alias_declaration_502 <alias_declaration_rules.html#alias-declaration-502>`_
|
||||
|
|
|
|||
|
|
@ -26,6 +26,29 @@ This rule checks the indent of the **exit** keyword.
|
|||
|
||||
exit;
|
||||
|
||||
exit_statement_301
|
||||
##################
|
||||
|
||||
|phase_4| |error| |indent|
|
||||
|
||||
This rule checks the indent of the label.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
end if;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
end if;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
exit_statement_500
|
||||
##################
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,27 @@ This rule checks the indentation of the **next** keyword.
|
|||
next when condition;
|
||||
end function;
|
||||
|
||||
next_statement_301
|
||||
##################
|
||||
|
||||
|phase_4| |error| |indent|
|
||||
|
||||
This rule checks the indentation of the label.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
next_label : next when condition;
|
||||
end function;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
next_label : next when condition;
|
||||
end function;
|
||||
|
||||
next_statement_500
|
||||
##################
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,27 @@ This rule checks the indentation of the **null** keyword.
|
|||
null;
|
||||
end loop;
|
||||
|
||||
null_statement_301
|
||||
##################
|
||||
|
||||
|phase_4| |error| |indent|
|
||||
|
||||
This rule checks the indentation of the label.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
null_label : null;
|
||||
end loop;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
null_label : null;
|
||||
end loop;
|
||||
|
||||
null_statement_500
|
||||
##################
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,27 @@
|
|||
Protected Type Body Rules
|
||||
-------------------------
|
||||
|
||||
protected_type_body_300
|
||||
#######################
|
||||
|
||||
|phase_4| |error| |indent|
|
||||
|
||||
This rule checks the indent of the end protected type body declaration.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
protected_type_body_500
|
||||
#######################
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,27 @@
|
|||
Protected Type Rules
|
||||
--------------------
|
||||
|
||||
protected_type_300
|
||||
##################
|
||||
|
||||
|phase_4| |error| |indent|
|
||||
|
||||
This rule checks the indent of the end protected type declaration.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
protected_type_500
|
||||
##################
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ Case::Keyword Rule Group
|
|||
Rules Enforcing Case::Keyword Rule Group
|
||||
########################################
|
||||
|
||||
* `aggregate_500 <../aggregate_rules.html#aggregate-500>`_
|
||||
* `alias_declaration_500 <../alias_declaration_rules.html#alias-declaration-500>`_
|
||||
* `alias_declaration_501 <../alias_declaration_rules.html#alias-declaration-501>`_
|
||||
* `architecture_004 <../architecture_rules.html#architecture-004>`_
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ Case Rule Group
|
|||
Rules Enforcing Case Rule Group
|
||||
###############################
|
||||
|
||||
* `aggregate_500 <../aggregate_rules.html#aggregate-500>`_
|
||||
* `alias_declaration_500 <../alias_declaration_rules.html#alias-declaration-500>`_
|
||||
* `alias_declaration_501 <../alias_declaration_rules.html#alias-declaration-501>`_
|
||||
* `alias_declaration_502 <../alias_declaration_rules.html#alias-declaration-502>`_
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ Rules Enforcing Indent Rule Group
|
|||
* `block_301 <../block_rules.html#block-301>`_
|
||||
* `block_302 <../block_rules.html#block-302>`_
|
||||
* `case_001 <../case_rules.html#case-001>`_
|
||||
* `case_300 <../case_rules.html#case-300>`_
|
||||
* `comment_010 <../comment_rules.html#comment-010>`_
|
||||
* `component_001 <../component_rules.html#component-001>`_
|
||||
* `component_009 <../component_rules.html#component-009>`_
|
||||
|
|
@ -28,6 +29,7 @@ Rules Enforcing Indent Rule Group
|
|||
* `entity_009 <../entity_rules.html#entity-009>`_
|
||||
* `entity_300 <../entity_rules.html#entity-300>`_
|
||||
* `exit_statement_300 <../exit_statement_rules.html#exit-statement-300>`_
|
||||
* `exit_statement_301 <../exit_statement_rules.html#exit-statement-301>`_
|
||||
* `file_001 <../file_rules.html#file-001>`_
|
||||
* `function_001 <../function_rules.html#function-001>`_
|
||||
* `function_008 <../function_rules.html#function-008>`_
|
||||
|
|
@ -56,7 +58,9 @@ Rules Enforcing Indent Rule Group
|
|||
* `loop_statement_301 <../loop_statement_rules.html#loop-statement-301>`_
|
||||
* `loop_statement_302 <../loop_statement_rules.html#loop-statement-302>`_
|
||||
* `next_statement_300 <../next_statement_rules.html#next-statement-300>`_
|
||||
* `next_statement_301 <../next_statement_rules.html#next-statement-301>`_
|
||||
* `null_statement_300 <../null_statement_rules.html#null-statement-300>`_
|
||||
* `null_statement_301 <../null_statement_rules.html#null-statement-301>`_
|
||||
* `package_001 <../package_rules.html#package-001>`_
|
||||
* `package_015 <../package_rules.html#package-015>`_
|
||||
* `package_body_300 <../package_body_rules.html#package-body-300>`_
|
||||
|
|
@ -77,6 +81,8 @@ Rules Enforcing Indent Rule Group
|
|||
* `process_001 <../process_rules.html#process-001>`_
|
||||
* `process_003 <../process_rules.html#process-003>`_
|
||||
* `process_006 <../process_rules.html#process-006>`_
|
||||
* `protected_type_300 <../protected_type_rules.html#protected-type-300>`_
|
||||
* `protected_type_body_300 <../protected_type_body_rules.html#protected-type-body-300>`_
|
||||
* `record_type_definition_300 <../record_type_definition_rules.html#record-type-definition-300>`_
|
||||
* `record_type_definition_301 <../record_type_definition_rules.html#record-type-definition-301>`_
|
||||
* `report_statement_300 <../report_statement_rules.html#report-statement-300>`_
|
||||
|
|
@ -93,3 +99,4 @@ Rules Enforcing Indent Rule Group
|
|||
* `variable_001 <../variable_rules.html#variable-001>`_
|
||||
* `variable_assignment_001 <../variable_assignment_rules.html#variable-assignment-001>`_
|
||||
* `wait_001 <../wait_rules.html#wait-001>`_
|
||||
* `wait_300 <../wait_rules.html#wait-300>`_
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ The rules are divided into categories depending on the part of the VHDL code bei
|
|||
:maxdepth: 2
|
||||
|
||||
after_rules.rst
|
||||
aggregate_rules.rst
|
||||
alias_declaration_rules.rst
|
||||
architecture_rules.rst
|
||||
assert_rules.rst
|
||||
|
|
|
|||
|
|
@ -31,6 +31,32 @@ Proper indentation enhances comprehension.
|
|||
wait on a,b;
|
||||
wait until a = '0';
|
||||
|
||||
wait_300
|
||||
########
|
||||
|
||||
|phase_4| |error| |indent|
|
||||
|
||||
This rule checks for indentation of the label.
|
||||
Proper indentation enhances comprehension.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
begin
|
||||
|
||||
wait on a,b;
|
||||
wait_label : wait until a = '0';
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
begin
|
||||
|
||||
wait on a,b;
|
||||
wait_label : wait until a = '0';
|
||||
|
||||
wait_500
|
||||
########
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,148 @@
|
|||
|
||||
architecture rtl of test is
|
||||
|
||||
signal sig : signed := (others => '0');
|
||||
|
||||
function my_func (
|
||||
test : t_counter := (others => '0')
|
||||
) return integer is
|
||||
begin
|
||||
return (others => '0');
|
||||
end function;
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a <=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
process is
|
||||
|
||||
constant con : signed := (others => '0');
|
||||
variable var : signed := (others => '0');
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a <=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
a :=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a := (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a :=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
case expression is
|
||||
|
||||
when others =>
|
||||
|
||||
null;
|
||||
|
||||
end case;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
||||
architecture rtl of test is
|
||||
|
||||
signal sig : signed := (others => '0');
|
||||
|
||||
function my_func (
|
||||
test : t_counter := (others => '0')
|
||||
) return integer is
|
||||
begin
|
||||
return (others => '0');
|
||||
end function;
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a <=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
process is
|
||||
|
||||
constant con : signed := (others => '0');
|
||||
variable var : signed := (others => '0');
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a <=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
a :=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a := (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a :=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
case expression is
|
||||
|
||||
when others =>
|
||||
|
||||
null;
|
||||
|
||||
end case;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
|
||||
architecture rtl of test is
|
||||
|
||||
signal sig : signed := (OTHERS => '0');
|
||||
|
||||
function my_func (
|
||||
test : t_counter := (OTHERS => '0')
|
||||
) return integer is
|
||||
begin
|
||||
return (OTHERS => '0');
|
||||
end function;
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a <=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
process is
|
||||
|
||||
constant con : signed := (OTHERS => '0');
|
||||
variable var : signed := (OTHERS => '0');
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a <=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
a :=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a := (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a :=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
case expression is
|
||||
|
||||
when others =>
|
||||
|
||||
null;
|
||||
|
||||
end case;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
||||
architecture rtl of test is
|
||||
|
||||
signal sig : signed := (OTHERS => '0');
|
||||
|
||||
function my_func (
|
||||
test : t_counter := (OTHERS => '0')
|
||||
) return integer is
|
||||
begin
|
||||
return (OTHERS => '0');
|
||||
end function;
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a <=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
process is
|
||||
|
||||
constant con : signed := (OTHERS => '0');
|
||||
variable var : signed := (OTHERS => '0');
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a <=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
a :=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a := (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a :=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
case expression is
|
||||
|
||||
when others =>
|
||||
|
||||
null;
|
||||
|
||||
end case;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
|
||||
architecture rtl of test is
|
||||
|
||||
signal sig : signed := (others => '0');
|
||||
|
||||
function my_func (
|
||||
test : t_counter := (others => '0')
|
||||
) return integer is
|
||||
begin
|
||||
return (others => '0');
|
||||
end function;
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a <=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
process is
|
||||
|
||||
constant con : signed := (others => '0');
|
||||
variable var : signed := (others => '0');
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a <=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
a :=
|
||||
(
|
||||
1 => '1',
|
||||
others => '0'
|
||||
);
|
||||
a := (
|
||||
1 => '1',
|
||||
others => '0'
|
||||
) when condition else
|
||||
(others => '0');
|
||||
with condition select a :=
|
||||
(others => '1') when x,
|
||||
(others => '0') when others;
|
||||
|
||||
case expression is
|
||||
|
||||
when others =>
|
||||
|
||||
null;
|
||||
|
||||
end case;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
||||
architecture rtl of test is
|
||||
|
||||
signal sig : signed := (OTHERS => '0');
|
||||
|
||||
function my_func (
|
||||
test : t_counter := (OTHERS => '0')
|
||||
) return integer is
|
||||
begin
|
||||
return (OTHERS => '0');
|
||||
end function;
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a <=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
process is
|
||||
|
||||
constant con : signed := (OTHERS => '0');
|
||||
variable var : signed := (OTHERS => '0');
|
||||
|
||||
begin
|
||||
|
||||
a <=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a <= (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a <=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
a :=
|
||||
(
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
);
|
||||
a := (
|
||||
1 => '1',
|
||||
OTHERS => '0'
|
||||
) when condition else
|
||||
(OTHERS => '0');
|
||||
with condition select a :=
|
||||
(OTHERS => '1') when x,
|
||||
(OTHERS => '0') when others;
|
||||
|
||||
case expression is
|
||||
|
||||
when others =>
|
||||
|
||||
null;
|
||||
|
||||
end case;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import aggregate
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_500_test_input.vhd"))
|
||||
|
||||
lExpected_lower = []
|
||||
lExpected_lower.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_lower.vhd"), lExpected_lower)
|
||||
|
||||
lExpected_upper = []
|
||||
lExpected_upper.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_upper.vhd"), lExpected_upper)
|
||||
|
||||
|
||||
class test_aggregate_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
||||
def test_rule_500_lower(self):
|
||||
oRule = aggregate.rule_500()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "aggregate")
|
||||
self.assertEqual(oRule.identifier, "500")
|
||||
|
||||
lExpected = [78, 81, 84, 92, 96, 98, 100, 101, 105, 106, 113, 117, 119, 121, 122, 127, 131, 133, 135, 136]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
||||
def test_rule_500_upper(self):
|
||||
oRule = aggregate.rule_500()
|
||||
oRule.case = "upper"
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "aggregate")
|
||||
self.assertEqual(oRule.identifier, "500")
|
||||
|
||||
lExpected = [4, 7, 10, 18, 22, 24, 26, 27, 31, 32, 39, 43, 45, 47, 48, 53, 57, 59, 61, 62]
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
||||
def test_fix_rule_500_lower(self):
|
||||
oRule = aggregate.rule_500()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected_lower, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
||||
def test_fix_rule_500_upper(self):
|
||||
oRule = aggregate.rule_500()
|
||||
oRule.case = "upper"
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected_upper, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
architecture ARCH of ENTITY is
|
||||
|
||||
begin
|
||||
|
||||
PROC_1 : process (a, b, c) is
|
||||
begin
|
||||
|
||||
my_case_statement_label : case boolean_1 is
|
||||
|
||||
when STATE_1 =>
|
||||
|
||||
a <= b;
|
||||
b <= c;
|
||||
c <= d;
|
||||
|
||||
end case;
|
||||
|
||||
-- Violations below
|
||||
|
||||
my_case_statement_label : case boolean_1 is
|
||||
|
||||
when STATE_1 =>
|
||||
|
||||
a <= b;
|
||||
b <= c;
|
||||
c <= d;
|
||||
|
||||
end case;
|
||||
|
||||
my_case_statement_label : case boolean_1 is
|
||||
|
||||
when STATE_1 =>
|
||||
|
||||
a <= b;
|
||||
b <= c;
|
||||
c <= d;
|
||||
|
||||
end case;
|
||||
|
||||
end process PROC_1;
|
||||
|
||||
end architecture ARCH;
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
architecture ARCH of ENTITY is
|
||||
|
||||
begin
|
||||
|
||||
PROC_1 : process (a, b, c) is
|
||||
begin
|
||||
|
||||
my_case_statement_label : case boolean_1 is
|
||||
|
||||
when STATE_1 =>
|
||||
|
||||
a <= b;
|
||||
b <= c;
|
||||
c <= d;
|
||||
|
||||
end case;
|
||||
|
||||
-- Violations below
|
||||
|
||||
my_case_statement_label : case boolean_1 is
|
||||
|
||||
when STATE_1 =>
|
||||
|
||||
a <= b;
|
||||
b <= c;
|
||||
c <= d;
|
||||
|
||||
end case;
|
||||
|
||||
my_case_statement_label : case boolean_1 is
|
||||
|
||||
when STATE_1 =>
|
||||
|
||||
a <= b;
|
||||
b <= c;
|
||||
c <= d;
|
||||
|
||||
end case;
|
||||
|
||||
end process PROC_1;
|
||||
|
||||
end architecture ARCH;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import case
|
||||
|
||||
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_case_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 = case.rule_300()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "case")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [21, 31]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_300(self):
|
||||
oRule = case.rule_300()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -8,9 +8,7 @@ begin
|
|||
|
||||
exit;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
exit_label : exit;
|
||||
exit;
|
||||
|
||||
end process;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ begin
|
|||
|
||||
exit;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
exit_label : exit;
|
||||
exit;
|
||||
|
||||
end process;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
architecture rtl of fifo is
|
||||
|
||||
begin
|
||||
|
||||
process is begin
|
||||
exit_label : exit;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
architecture rtl of fifo is
|
||||
|
||||
begin
|
||||
|
||||
process is begin
|
||||
exit_label : exit;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -30,7 +30,7 @@ class test_exit_statement_rule(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, "exit_statement")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [9, 13]
|
||||
lExpected = [9, 11]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import exit_statement
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_301_test_input.vhd"))
|
||||
|
||||
dIndentMap = utils.read_indent_file()
|
||||
|
||||
lExpected = []
|
||||
lExpected.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_301_test_input.fixed.vhd"), lExpected, False)
|
||||
|
||||
|
||||
class test_exit_statement_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
self.oFile.set_indent_map(dIndentMap)
|
||||
|
||||
def test_rule_301(self):
|
||||
oRule = exit_statement.rule_301()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "exit_statement")
|
||||
self.assertEqual(oRule.identifier, "301")
|
||||
|
||||
lExpected = [9, 11]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_301(self):
|
||||
oRule = exit_statement.rule_301()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -5,8 +5,6 @@ architecture RTL of FIFO is
|
|||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next when condition;
|
||||
|
|
@ -22,8 +20,6 @@ architecture RTL of FIFO is
|
|||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next when condition;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ architecture RTL of FIFO is
|
|||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next when condition;
|
||||
|
|
@ -22,8 +20,6 @@ architecture RTL of FIFO is
|
|||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next my_loop when condition;
|
||||
next when condition;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
next_label : next my_loop when condition;
|
||||
next_label : next my_loop when condition;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -18,7 +18,7 @@ lExpected.append("")
|
|||
utils.read_file(os.path.join(sTestDir, "rule_300_test_input.fixed.vhd"), lExpected)
|
||||
|
||||
|
||||
class test_return_statement_rule(unittest.TestCase):
|
||||
class test_next_statement_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
|
@ -30,7 +30,7 @@ class test_return_statement_rule(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, "next_statement")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [25, 26, 27, 28, 29, 30, 31, 32]
|
||||
lExpected = [23, 24, 25, 26, 27, 28]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import next_statement
|
||||
|
||||
sTestDir = os.path.dirname(__file__)
|
||||
|
||||
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_301_test_input.vhd"))
|
||||
|
||||
dIndentMap = utils.read_indent_file()
|
||||
|
||||
lExpected = []
|
||||
lExpected.append("")
|
||||
utils.read_file(os.path.join(sTestDir, "rule_301_test_input.fixed.vhd"), lExpected)
|
||||
|
||||
|
||||
class test_return_statement_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
self.oFile.set_indent_map(dIndentMap)
|
||||
|
||||
def test_rule_301(self):
|
||||
oRule = next_statement.rule_301()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "next_statement")
|
||||
self.assertEqual(oRule.identifier, "301")
|
||||
|
||||
lExpected = [19, 20]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_301(self):
|
||||
oRule = next_statement.rule_301()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -20,7 +20,7 @@ lExpected_upper.append("")
|
|||
utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_upper.vhd"), lExpected_upper)
|
||||
|
||||
|
||||
class test_return_statement_rule(unittest.TestCase):
|
||||
class test_next_statement_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ lExpected_upper.append("")
|
|||
utils.read_file(os.path.join(sTestDir, "rule_501_test_input.fixed_upper.vhd"), lExpected_upper)
|
||||
|
||||
|
||||
class test_return_statement_rule(unittest.TestCase):
|
||||
class test_next_statement_rule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.oFile = vhdlFile.vhdlFile(lFile)
|
||||
self.assertIsNone(eError)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ architecture RTL of FIFO is
|
|||
loop
|
||||
|
||||
null;
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
|
|
@ -17,9 +16,7 @@ architecture RTL of FIFO is
|
|||
loop
|
||||
|
||||
null;
|
||||
null_label : null;
|
||||
null;
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ architecture RTL of FIFO is
|
|||
loop
|
||||
|
||||
null;
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
|
|
@ -17,9 +16,7 @@ architecture RTL of FIFO is
|
|||
loop
|
||||
|
||||
null;
|
||||
null_label : null;
|
||||
null;
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
null_label : null;
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
architecture RTL of FIFO is
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
function func1 return integer is begin
|
||||
|
||||
loop
|
||||
|
||||
null_label : null;
|
||||
null_label : null;
|
||||
|
||||
end loop;
|
||||
|
||||
end function func1;
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
@ -30,7 +30,7 @@ class test_null_statement_rule(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, "null_statement")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [19, 20, 21, 22]
|
||||
lExpected = [18, 19]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import null_statement
|
||||
|
||||
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_null_statement_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 = null_statement.rule_300()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "null_statement")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [18, 19]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_300(self):
|
||||
oRule = null_statement.rule_300()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
package test is
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
end package test;
|
||||
|
||||
architecture rtl of test is
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
begin
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
package test is
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
end package test;
|
||||
|
||||
architecture rtl of test is
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
begin
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import protected_type
|
||||
|
||||
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_protected_type_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 = protected_type.rule_300()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "protected_type")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [8, 11, 21, 24]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_300(self):
|
||||
oRule = protected_type.rule_300()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
package body test is
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
end package body test;
|
||||
|
||||
architecture rtl of test is
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
begin
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
package body test is
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
end package body test;
|
||||
|
||||
architecture rtl of test is
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
begin
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import protected_type_body
|
||||
|
||||
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_protected_type_body_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 = protected_type_body.rule_300()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "protected_type_body")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [8, 11, 21, 24]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_300(self):
|
||||
oRule = protected_type_body.rule_300()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
entity ENTITY1 is
|
||||
generic (
|
||||
wait_generic : std_logic := '0'
|
||||
);
|
||||
port (
|
||||
wait_port : std_logic := '1'
|
||||
);
|
||||
end entity ENTITY1;
|
||||
|
||||
architecture ARCH of ENTITY1 is
|
||||
|
||||
signal wait_for_something : std_logic;
|
||||
|
||||
component ENTITY2 is
|
||||
generic (
|
||||
wait_generic : std_logic := '0'
|
||||
);
|
||||
port (
|
||||
wait_port : std_logic := '1'
|
||||
);
|
||||
end component ENTITY2;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
PROC1 : process (wait_for_something) is
|
||||
|
||||
-- wait <-- this should not be classified as a wait
|
||||
variable wait_for_other_thing : std_logic;
|
||||
|
||||
begin
|
||||
|
||||
wait_label : wait for 10ns;
|
||||
wait_label : wait on a,b;
|
||||
wait_label : wait until a = '0';
|
||||
|
||||
end process PROC1;
|
||||
|
||||
U_ENTITY2 : ENTITY2
|
||||
generic map (
|
||||
wait_generic => '0'
|
||||
)
|
||||
port map (
|
||||
wait_port => '1'
|
||||
);
|
||||
|
||||
end architecture ARCH;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
entity ENTITY1 is
|
||||
generic (
|
||||
wait_generic : std_logic := '0'
|
||||
);
|
||||
port (
|
||||
wait_port : std_logic := '1'
|
||||
);
|
||||
end entity ENTITY1;
|
||||
|
||||
architecture ARCH of ENTITY1 is
|
||||
|
||||
signal wait_for_something : std_logic;
|
||||
|
||||
component ENTITY2 is
|
||||
generic (
|
||||
wait_generic : std_logic := '0'
|
||||
);
|
||||
port (
|
||||
wait_port : std_logic := '1'
|
||||
);
|
||||
end component ENTITY2;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
PROC1 : process (wait_for_something) is
|
||||
|
||||
-- wait <-- this should not be classified as a wait
|
||||
variable wait_for_other_thing : std_logic;
|
||||
|
||||
begin
|
||||
|
||||
wait_label : wait for 10ns;
|
||||
wait_label : wait on a,b;
|
||||
wait_label : wait until a = '0';
|
||||
|
||||
end process PROC1;
|
||||
|
||||
U_ENTITY2 : ENTITY2
|
||||
generic map (
|
||||
wait_generic => '0'
|
||||
)
|
||||
port map (
|
||||
wait_port => '1'
|
||||
);
|
||||
|
||||
end architecture ARCH;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
from vsg import vhdlFile
|
||||
from vsg.rules import wait
|
||||
|
||||
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_wait_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 = wait.rule_300()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, "wait")
|
||||
self.assertEqual(oRule.identifier, "300")
|
||||
|
||||
lExpected = [34, 36]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
||||
def test_fix_rule_300(self):
|
||||
oRule = wait.rule_300()
|
||||
|
||||
oRule.fix(self.oFile)
|
||||
|
||||
lActual = self.oFile.get_lines()
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
@ -100,6 +100,7 @@ from .experiment import Rule as experiment
|
|||
|
||||
from vsg.rules import alias_declaration
|
||||
from vsg.rules import after
|
||||
from vsg.rules import aggregate
|
||||
from vsg.rules import architecture
|
||||
from vsg.rules import assert_statement
|
||||
from vsg.rules import attribute
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .rule_500 import rule_500
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_case_in_range_bounded_by_tokens as Rule
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.choice.others_keyword)
|
||||
|
||||
oStart = token.aggregate.open_parenthesis
|
||||
oEnd = token.aggregate.close_parenthesis
|
||||
|
||||
|
||||
class rule_500(Rule):
|
||||
"""
|
||||
This rule checks the *others* keyword in aggregates has proper case.
|
||||
|
||||
|configuring_uppercase_and_lowercase_rules_link|
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
signal counter : t_counter := (OTHERS => '1');
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
signal counter : t_counter := (others => '1');
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens, oStart, oEnd)
|
||||
self.groups.append("case::keyword")
|
||||
|
|
@ -23,4 +23,5 @@ from .rule_020 import rule_020
|
|||
from .rule_021 import rule_021
|
||||
from .rule_200 import rule_200
|
||||
from .rule_201 import rule_201
|
||||
from .rule_300 import rule_300
|
||||
from .rule_500 import rule_500
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_indent
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.case_statement.case_label)
|
||||
|
||||
|
||||
class rule_300(token_indent):
|
||||
"""
|
||||
This rule checks the indentation of the label.
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
case_label : case data is
|
||||
|
||||
end case;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
case_label : case data is
|
||||
|
||||
end case;
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens)
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .rule_300 import rule_300
|
||||
from .rule_301 import rule_301
|
||||
from .rule_500 import rule_500
|
||||
from .rule_501 import rule_501
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from vsg import token
|
|||
from vsg.rules import token_indent
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.exit_statement.label)
|
||||
lTokens.append(token.exit_statement.exit_keyword)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_indent
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.exit_statement.label)
|
||||
|
||||
|
||||
class rule_301(token_indent):
|
||||
"""
|
||||
This rule checks the indent of the label.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
end if;
|
||||
|
||||
exit_label : exit;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
end if;
|
||||
|
||||
exit_label : exit;
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens)
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .rule_300 import rule_300
|
||||
from .rule_301 import rule_301
|
||||
from .rule_500 import rule_500
|
||||
from .rule_501 import rule_501
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from vsg import token
|
|||
from vsg.rules import token_indent as Rule
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.next_statement.label)
|
||||
lTokens.append(token.next_statement.next_keyword)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_indent as Rule
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.next_statement.label)
|
||||
|
||||
|
||||
class rule_301(Rule):
|
||||
"""
|
||||
This rule checks the indentation of the label.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
next_label : next when condition;
|
||||
end function;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
next_label : next when condition;
|
||||
end function;
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens)
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .rule_300 import rule_300
|
||||
from .rule_301 import rule_301
|
||||
from .rule_500 import rule_500
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from vsg import token
|
|||
from vsg.rules import token_indent as Rule
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.null_statement.label)
|
||||
lTokens.append(token.null_statement.null_keyword)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_indent as Rule
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.null_statement.label)
|
||||
|
||||
|
||||
class rule_301(Rule):
|
||||
"""
|
||||
This rule checks the indentation of the label.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
null_label : null;
|
||||
end loop;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
null_label : null;
|
||||
end loop;
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens)
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .rule_300 import rule_300
|
||||
from .rule_500 import rule_500
|
||||
from .rule_501 import rule_501
|
||||
from .rule_502 import rule_502
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_indent
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.protected_type_declaration.end_keyword)
|
||||
|
||||
|
||||
class rule_300(token_indent):
|
||||
"""
|
||||
This rule checks the indent of the end protected type declaration.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected
|
||||
end protected;
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens)
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .rule_300 import rule_300
|
||||
from .rule_500 import rule_500
|
||||
from .rule_501 import rule_501
|
||||
from .rule_502 import rule_502
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_indent
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.protected_type_body.end_keyword)
|
||||
|
||||
|
||||
class rule_300(token_indent):
|
||||
"""
|
||||
This rule checks the indent of the end protected type body declaration.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
type flag_pt is protected body
|
||||
end protected body;
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .rule_001 import rule_001
|
||||
from .rule_300 import rule_300
|
||||
from .rule_500 import rule_500
|
||||
from .rule_501 import rule_501
|
||||
from .rule_502 import rule_502
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from vsg.rules import token_indent
|
|||
|
||||
lTokens = []
|
||||
lTokens.append(token.wait_statement.wait_keyword)
|
||||
lTokens.append(token.wait_statement.label)
|
||||
|
||||
|
||||
class rule_001(token_indent):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import token
|
||||
from vsg.rules import token_indent
|
||||
|
||||
lTokens = []
|
||||
lTokens.append(token.wait_statement.label)
|
||||
|
||||
|
||||
class rule_300(token_indent):
|
||||
"""
|
||||
This rule checks for indentation of the label.
|
||||
Proper indentation enhances comprehension.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
begin
|
||||
|
||||
wait on a,b;
|
||||
wait_label : wait until a = '0';
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
begin
|
||||
|
||||
wait on a,b;
|
||||
wait_label : wait until a = '0';
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(lTokens)
|
||||
Loading…
Reference in New Issue