108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
if not self._checkSuggestions(sExceptedSuggs, sFoundSuggs):
print("\n# Line num: " + sLineNum + \
"\n> to check: " + _fuckBackslashUTF8(sTextToCheck) + \
"\n expected: " + sExceptedSuggs + \
"\n found: " + sFoundSuggs + \
"\n errors: \n" + sListErr)
nUnexpectedErrors += 1
print("Tests with expected errors:", nTestWithExpectedError, " and suggestions:", nTestWithExpectedErrorAndSugg, ":{:.4}%".format(nTestWithExpectedErrorAndSugg/nTestWithExpectedError*100))
if nUnexpectedErrors:
print("Unexpected errors:", nUnexpectedErrors)
# untested rules
aUntestedRules = set()
for _, sOpt, sLineId, sRuleId in gc_engine.listRules():
sRuleId = sRuleId.rstrip("0123456789")
if sOpt != "@@@@" and sRuleId not in self._aTestedRules and not re.search("^[0-9]+[sp]$|^[pd]_", sRuleId):
aUntestedRules.add(f"{sLineId}/{sRuleId}")
if aUntestedRules:
print()
|
|
|
>
>
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
if not self._checkSuggestions(sExceptedSuggs, sFoundSuggs):
print("\n# Line num: " + sLineNum + \
"\n> to check: " + _fuckBackslashUTF8(sTextToCheck) + \
"\n expected: " + sExceptedSuggs + \
"\n found: " + sFoundSuggs + \
"\n errors: \n" + sListErr)
nUnexpectedErrors += 1
print("Tests with expected errors:", nTestWithExpectedError, " and suggestions:", nTestWithExpectedErrorAndSugg, "> {:.4} %".format(nTestWithExpectedErrorAndSugg/nTestWithExpectedError*100))
if nUnexpectedErrors:
print("Unexpected errors:", nUnexpectedErrors)
self._showUntestedRules()
def _showUntestedRules (self):
aUntestedRules = set()
for _, sOpt, sLineId, sRuleId in gc_engine.listRules():
sRuleId = sRuleId.rstrip("0123456789")
if sOpt != "@@@@" and sRuleId not in self._aTestedRules and not re.search("^[0-9]+[sp]$|^[pd]_", sRuleId):
aUntestedRules.add(f"{sLineId}/{sRuleId}")
if aUntestedRules:
print()
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
sRes = " " * len(sLine)
for i, m in enumerate(self._zError.finditer(sLine)):
nStart = m.start() - (4 * i)
nEnd = m.end() - (4 * (i+1))
sRes = sRes[:nStart] + "~" * (nEnd - nStart) + sRes[nEnd:-4]
return sRes
def _checkSuggestions (self, sExceptedSuggs, sFoundSuggs):
lAllExpectedSuggs = sExceptedSuggs.split("|||")
lAllFoundSuggs = sFoundSuggs.split("|||")
if len(lAllExpectedSuggs) != len(lAllFoundSuggs):
return False
for sExceptedSuggs, sFoundSuggs in zip(lAllExpectedSuggs, lAllFoundSuggs):
if set(sExceptedSuggs.split("|")) != set(sFoundSuggs.split("|")):
return False
return True
|
|
|
|
|
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
sRes = " " * len(sLine)
for i, m in enumerate(self._zError.finditer(sLine)):
nStart = m.start() - (4 * i)
nEnd = m.end() - (4 * (i+1))
sRes = sRes[:nStart] + "~" * (nEnd - nStart) + sRes[nEnd:-4]
return sRes
def _checkSuggestions (self, sAllExceptedSuggs, sAllFoundSuggs):
lAllExpectedSuggs = sAllExceptedSuggs.split("|||")
lAllFoundSuggs = sAllFoundSuggs.split("|||")
if len(lAllExpectedSuggs) != len(lAllFoundSuggs):
return False
for sExceptedSuggs, sFoundSuggs in zip(lAllExpectedSuggs, lAllFoundSuggs):
if set(sExceptedSuggs.split("|")) != set(sFoundSuggs.split("|")):
return False
return True
|