Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update characterization for plural_rules, datetime skeletons, and other small changes #347

Merged
merged 7 commits into from
Nov 15, 2024
46 changes: 41 additions & 5 deletions verifier/testreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,14 @@ def characterize_results_by_options(self, test_list, category):
# User self.failing_tests, looking at options
results = defaultdict(lambda : defaultdict(list))
results['locale'] = {} # Dictionary of labels for each locale

# Look at particular test types
if self.test_type == 'plural_rules' and test_list:
self.characterize_plural_rules_tests(test_list, results)

if self.test_type == 'datetime_fmt' and test_list:
self.characterize_datetime_tests(test_list, results)

for test in test_list:
# Get input_data, if available
input_data = test.get('input_data', None)
Expand Down Expand Up @@ -699,6 +707,33 @@ def characterize_results_by_options(self, test_list, category):

return results


def characterize_plural_rules_tests(self, test_list, results):
# look for consistencies with plural rules test
for test in test_list:
label = test['label']
sample = test['input_data']['sample']
sample_type = 'integer sample'
if sample.find('c') >= 0:
sample_type = 'compact sample'
elif sample.find('.') >= 0:
sample_type = 'float sample'
elif sample.find('e') >= 0:
sample_type = 'exponential sample'
results.setdefault(sample_type, []).append(label)
return


def characterize_datetime_tests(self, test_list, results):
# look for consistencies with datetime_fmt test
for test in test_list:
label = test['label']
if 'skeleton' in test['input_data']:
skeleton_str = 'skeleton: ' + test['input_data']['skeleton']
results.setdefault(skeleton_str, []).append(label)

return

# TODO: Use the following function to update lists.
def add_to_results_by_key(self, label, results, input_data, test, key_list):
if input_data:
Expand All @@ -724,8 +759,8 @@ def add_to_results_by_key(self, label, results, input_data, test, key_list):
def check_simple_text_diffs(self, test_list, category):
results = defaultdict(list)
all_checks = ['insert', 'delete', 'insert_digit', 'insert_space', 'delete_digit',
'delete_space', 'replace_digit', 'replace_dff', 'whitespace_diff',
'replace', 'parens']
'delete_space', 'replace_digit', 'replace_dff', 'replace_diff', 'whitespace_diff',
'replace', 'diff_in_()', 'parens', '() --> []', '[] --> ()']
for check in all_checks:
results[check] = set()

Expand Down Expand Up @@ -765,7 +800,7 @@ def check_simple_text_diffs(self, test_list, category):
# Difference is in type of white space
results['whitespace_diff'].add(label)
else:
results['replace_dff'].add(label)
results['replace_diff'].add(label)

elif kind == "delete":
if old_val.isdigit():
Expand Down Expand Up @@ -804,6 +839,7 @@ def check_simple_text_diffs(self, test_list, category):

elif x[2] in ['+', '0', '+0']:
results['replace_dff'].add(label)
# Check if replacement is entirely within parentheses
else:
results['insert'].add(label)
if x[0] == '-':
Expand All @@ -814,11 +850,11 @@ def check_simple_text_diffs(self, test_list, category):
if '[' in expected and '(' in actual:
actual_parens = actual.replace('(', '[').replace(')', ']')
if actual_parens == expected:
results['parens'].add(label)
results['() --> []'].add(label)
elif '(' in expected and '[' in actual:
actual_parens = actual.replace('[', '(').replace(')', ']')
if actual_parens == expected:
results['parens'].add(label)
results['[]--> ()'].add(label)
except KeyError:
# a non-string result
continue
Expand Down
Loading