Issue#1366: Added tests for subprogram instantiation structure rules.

This commit is contained in:
JHertz5 2024-12-29 11:08:54 +00:00
parent 9087f795c8
commit 0d884952ea
15 changed files with 500 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function
my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc
is new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function
my_func is new my_generic_func
generic map (
test => 2
);
procedure
my_proc is new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function my_func
is new my_generic_func
generic map (
test => 2
);
procedure
my_proc is new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function
my_func is new my_generic_func
generic map (
test => 2
);
procedure
my_proc is new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function my_func is
new my_generic_func
generic map (
test => 2
);
procedure my_proc is
new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function my_func
is new my_generic_func
generic map (
test => 2
);
procedure my_proc
is new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function my_func is new
my_generic_func
generic map (
test => 2
);
procedure my_proc is new
my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function my_func is
new my_generic_func
generic map (
test => 2
);
procedure my_proc is
new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,26 @@
package test is
function my_func is new my_generic_func
generic map (
test => 2
);
procedure my_proc is new my_generic_proc
generic map (
test => 2
);
function my_func is new
my_generic_func
generic map (
test => 2
);
procedure my_proc is new
my_generic_proc
generic map (
test => 2
);
end package test;

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
import os
import unittest
from tests import utils
from vsg import vhdlFile
from vsg.rules import subprogram_instantiation
sTestDir = os.path.dirname(__file__)
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_001_test_input.vhd"))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_001_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_001(self):
oRule = subprogram_instantiation.rule_001()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "subprogram_instantiation")
self.assertEqual(oRule.identifier, "001")
lExpected = [20]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_001(self):
oRule = subprogram_instantiation.rule_001()
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
import os
import unittest
from tests import utils
from vsg import vhdlFile
from vsg.rules import subprogram_instantiation
sTestDir = os.path.dirname(__file__)
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_002_test_input.vhd"))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_002_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_002(self):
oRule = subprogram_instantiation.rule_002()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "subprogram_instantiation")
self.assertEqual(oRule.identifier, "002")
lExpected = [14]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_002(self):
oRule = subprogram_instantiation.rule_002()
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
import os
import unittest
from tests import utils
from vsg import vhdlFile
from vsg.rules import subprogram_instantiation
sTestDir = os.path.dirname(__file__)
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_003_test_input.vhd"))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_003_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_003(self):
oRule = subprogram_instantiation.rule_003()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "subprogram_instantiation")
self.assertEqual(oRule.identifier, "003")
lExpected = [14, 20]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_003(self):
oRule = subprogram_instantiation.rule_003()
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
import os
import unittest
from tests import utils
from vsg import vhdlFile
from vsg.rules import subprogram_instantiation
sTestDir = os.path.dirname(__file__)
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_004_test_input.vhd"))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_004_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_004(self):
oRule = subprogram_instantiation.rule_004()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "subprogram_instantiation")
self.assertEqual(oRule.identifier, "004")
lExpected = [14, 20]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_004(self):
oRule = subprogram_instantiation.rule_004()
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
import os
import unittest
from tests import utils
from vsg import vhdlFile
from vsg.rules import subprogram_instantiation
sTestDir = os.path.dirname(__file__)
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_005_test_input.vhd"))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_005_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_005(self):
oRule = subprogram_instantiation.rule_005()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "subprogram_instantiation")
self.assertEqual(oRule.identifier, "005")
lExpected = [14, 20]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_005(self):
oRule = subprogram_instantiation.rule_005()
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])