Adding tests for relaxedCamelCase and RelaxedPascalCase.
This commit is contained in:
parent
b9607b0267
commit
75cbdfe002
|
|
@ -75,3 +75,13 @@ entity my_fifo_green_red_blue is end entity;
|
|||
entity e_my_fifo_green_red_blue is end entity;
|
||||
entity my_fifo_green_red_blue_a is end entity;
|
||||
entity e_my_fifo_green_red_blue_a is end entity;
|
||||
|
||||
-- Test RelaxedPascalCase
|
||||
|
||||
entity myfifo is end entity;
|
||||
entity myfifo is end entity;
|
||||
entity myfifo is end entity;
|
||||
entity myfifo is end entity;
|
||||
entity myfifo is end entity;
|
||||
entity myfifo is end entity;
|
||||
entity myfifo is end entity;
|
||||
|
|
|
|||
|
|
@ -75,3 +75,13 @@ entity MY_FIFO_GREEN_RED_BLUE is end entity;
|
|||
entity E_MY_FIFO_GREEN_RED_BLUE is end entity;
|
||||
entity MY_FIFO_GREEN_RED_BLUE_A is end entity;
|
||||
entity E_MY_FIFO_GREEN_RED_BLUE_A is end entity;
|
||||
|
||||
-- Test RelaxedPascalCase
|
||||
|
||||
entity MYFIFO is end entity;
|
||||
entity MYFIFO is end entity;
|
||||
entity MYFIFO is end entity;
|
||||
entity MYFIFO is end entity;
|
||||
entity MYFIFO is end entity;
|
||||
entity MYFIFO is end entity;
|
||||
entity MYFIFO is end entity;
|
||||
|
|
|
|||
|
|
@ -75,3 +75,13 @@ entity My_Fifo_Green_Red_Blue is end entity;
|
|||
entity e_My_Fifo_Green_Red_Blue is end entity;
|
||||
entity My_Fifo_Green_Red_Blue_a is end entity;
|
||||
entity e_My_Fifo_Green_Red_Blue_a is end entity;
|
||||
|
||||
-- Test RelaxedPascalCase
|
||||
|
||||
entity MyFifo is end entity;
|
||||
entity MyFIfo is end entity;
|
||||
entity MyFIFo is end entity;
|
||||
entity MyFIFO is end entity;
|
||||
entity MyFiFo is end entity;
|
||||
entity MyFifO is end entity;
|
||||
entity MyFiFO is end entity;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -77,6 +78,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -118,6 +120,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -143,6 +146,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -168,6 +172,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([63, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -189,6 +194,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([57, 58, 59, 60])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -214,6 +220,32 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
||||
def test_rule_008_relaxedCamelCase(self):
|
||||
oRule = entity.rule_008()
|
||||
oRule.case = "relaxedCamelCase"
|
||||
|
||||
lExpected = []
|
||||
lExpected.extend([3, 4, 5])
|
||||
lExpected.extend([7, 8, 9, 10])
|
||||
lExpected.extend([13, 14, 15])
|
||||
lExpected.extend([17, 18, 19, 20])
|
||||
lExpected.extend([22, 23, 24, 25])
|
||||
lExpected.extend([27, 28, 29, 30])
|
||||
lExpected.extend([32, 33, 34, 35])
|
||||
lExpected.extend([38, 39, 40])
|
||||
lExpected.extend([42, 43, 44, 45])
|
||||
lExpected.extend([48, 49, 50])
|
||||
lExpected.extend([53, 54, 55])
|
||||
lExpected.extend([57, 58, 59, 60])
|
||||
lExpected.extend([63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -238,6 +270,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([83, 84])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -263,6 +296,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([83, 84])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -288,6 +322,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([83, 84])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -311,6 +346,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([83, 84])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -336,6 +372,31 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
lExpected.extend([83, 84])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
||||
def test_rule_008_RelaxedPascalCase(self):
|
||||
oRule = entity.rule_008()
|
||||
oRule.case = "RelaxedPascalCase"
|
||||
|
||||
lExpected = []
|
||||
lExpected.extend([2, 3, 4, 5])
|
||||
lExpected.extend([7, 8, 9, 10])
|
||||
lExpected.extend([12, 13, 14, 15])
|
||||
lExpected.extend([18, 19, 20])
|
||||
lExpected.extend([22, 23, 24, 25])
|
||||
lExpected.extend([27, 28, 29, 30])
|
||||
lExpected.extend([33, 34, 35])
|
||||
lExpected.extend([37, 38, 39, 40])
|
||||
lExpected.extend([43, 44, 45])
|
||||
lExpected.extend([47, 48, 49, 50])
|
||||
lExpected.extend([52, 53, 54, 55])
|
||||
lExpected.extend([58, 59, 60])
|
||||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([74, 75, 76, 77])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -360,6 +421,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -385,6 +447,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -410,6 +473,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([75, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -434,6 +498,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([57, 58, 59, 60])
|
||||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
@ -459,6 +524,7 @@ class test_entity_rule(unittest.TestCase):
|
|||
lExpected.extend([62, 63, 64, 65])
|
||||
lExpected.extend([69, 70, 71, 72])
|
||||
lExpected.extend([75, 76, 77])
|
||||
lExpected.extend([81, 82, 83, 84, 85, 86, 87])
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
|
||||
|
|
|
|||
|
|
@ -4,14 +4,10 @@ import re
|
|||
|
||||
from vsg import violation
|
||||
|
||||
# camelCase = re.compile("(?:[a-z])+(?:[a-z0-9])*((?:[A-Z])+(?:[a-z0-9])+)*")
|
||||
# PascalCase = re.compile("((?:[A-Z])+(?:[a-z0-9])+)+")
|
||||
# PascalSnakeCase = re.compile("(((?:[A-Z])+(?:[a-z0-9])*)+_?)+")
|
||||
|
||||
camelCase = re.compile("(?!.*[A-Z]{3})[a-z][a-zA-Z0-9]*")
|
||||
relaxedCamelCase = re.compile("(?:[a-z])+(?:[a-z0-9])*((?:[A-Z])+(?:[a-z0-9])+)*")
|
||||
relaxedCamelCase = re.compile("(?:[a-z])+(?:[a-z0-9])*((?:[A-Z])+(?:[a-z0-9])+)*([A-Z])?")
|
||||
PascalCase = re.compile("(?!.*[A-Z]{3})[A-Z][a-zA-Z0-9]*")
|
||||
RelaxedPascalCase = re.compile("((?:[A-Z])+(?:[a-z0-9])+)+")
|
||||
RelaxedPascalCase = re.compile("((?:[A-Z])+(?:[a-z0-9])+)+([A-Z]*)?")
|
||||
PascalSnakeCase = re.compile("(?!.*[A-Z]{3})[A-Z][a-z0-9]*(?:_[A-Z0-9][a-z0-9]*)*")
|
||||
|
||||
|
||||
|
|
@ -132,6 +128,13 @@ def check_for_camelcase(sActualValue, sPrefix, sWord, sSuffix, oToi, iIndex, iLi
|
|||
return create_case_violation(sActualValue, sExpectedValue, oToi, iIndex, iLine, sSolution)
|
||||
|
||||
|
||||
def check_for_relaxedcamelcase(sActualValue, sPrefix, sWord, sSuffix, oToi, iIndex, iLine, self):
|
||||
sExpectedValue = sPrefix + sWord + sSuffix
|
||||
if relaxedCamelCase.fullmatch(sWord) is None:
|
||||
sSolution = "Format " + sActualValue + " into relaxedCamelCase"
|
||||
return create_case_violation(sActualValue, sExpectedValue, oToi, iIndex, iLine, sSolution)
|
||||
|
||||
|
||||
def check_for_pascalcase(sActualValue, sPrefix, sWord, sSuffix, oToi, iIndex, iLine, self):
|
||||
sExpectedValue = sPrefix + sWord + sSuffix
|
||||
if PascalCase.fullmatch(sWord) is None:
|
||||
|
|
@ -139,6 +142,13 @@ def check_for_pascalcase(sActualValue, sPrefix, sWord, sSuffix, oToi, iIndex, iL
|
|||
return create_case_violation(sActualValue, sExpectedValue, oToi, iIndex, iLine, sSolution)
|
||||
|
||||
|
||||
def check_for_relaxedpascalcase(sActualValue, sPrefix, sWord, sSuffix, oToi, iIndex, iLine, self):
|
||||
sExpectedValue = sPrefix + sWord + sSuffix
|
||||
if RelaxedPascalCase.fullmatch(sWord) is None:
|
||||
sSolution = "Format " + sActualValue + " into RelaxedPascalCase"
|
||||
return create_case_violation(sActualValue, sExpectedValue, oToi, iIndex, iLine, sSolution)
|
||||
|
||||
|
||||
def check_for_pascal_snake_case(sActualValue, sPrefix, sWord, sSuffix, oToi, iIndex, iLine, self):
|
||||
sExpectedValue = sPrefix + sWord + sSuffix
|
||||
if PascalSnakeCase.fullmatch(sWord) is None:
|
||||
|
|
@ -235,8 +245,12 @@ def does_not_contain_any_alpha_characters(sObjectValue):
|
|||
dCase = {}
|
||||
dCase["camelCase"] = {}
|
||||
dCase["camelCase"]["check"] = check_for_camelcase
|
||||
dCase["relaxedCamelCase"] = {}
|
||||
dCase["relaxedCamelCase"]["check"] = check_for_relaxedcamelcase
|
||||
dCase["PascalCase"] = {}
|
||||
dCase["PascalCase"]["check"] = check_for_pascalcase
|
||||
dCase["RelaxedPascalCase"] = {}
|
||||
dCase["RelaxedPascalCase"]["check"] = check_for_relaxedpascalcase
|
||||
dCase["Pascal_Snake_Case"] = {}
|
||||
dCase["Pascal_Snake_Case"]["check"] = check_for_pascal_snake_case
|
||||
dCase["regex"] = {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue