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

Adding coll_nonignorable_short testing #94

Merged
merged 23 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
862d8e2
Adding coll_nonignorable_short testing
sven-oly Aug 18, 2023
0417b45
Update to boolean for node's collation test
sven-oly Aug 18, 2023
adf34b6
Update node collator to handle both shifted and non-ignorable
sven-oly Aug 19, 2023
c5ffa78
sort order of executors and tests
sven-oly Aug 19, 2023
623b8c8
Add rust nonignorable collation
sven-oly Aug 21, 2023
a04b86d
Fix node collator by adding test locale to call
sven-oly Aug 21, 2023
27fd473
remove unused collator_nonignorable.js
sven-oly Aug 21, 2023
3a06338
Integrate collation for ignorePuncuation on/off
sven-oly Aug 22, 2023
d54e684
Update collator data gen and Dart_web test
sven-oly Aug 22, 2023
c384fa8
Merge from Dart adding Number Format
sven-oly Aug 23, 2023
e31a3f3
Small update to generate script
sven-oly Aug 23, 2023
5bdf252
Rustfmt and update generate script
sven-oly Aug 23, 2023
aac93ef
More updates for collation
sven-oly Sep 5, 2023
21f4d87
dart_web working with new collation data
sven-oly Sep 5, 2023
b42eedc
Add line number to collation test data
sven-oly Sep 5, 2023
c700e0b
Dart fixes
mosuem Sep 6, 2023
cc1a663
Removing old testing source
sven-oly Sep 6, 2023
201529f
Merge pull request #2 from mosuem/AddIgnorableCollation
sven-oly Sep 6, 2023
f7eade1
Merge branch 'main' into AddIgnorableCollation
sven-oly Sep 6, 2023
18c39c2
Update name of test to collation_short
sven-oly Sep 6, 2023
49e4165
Update README and reporting details for collation
sven-oly Sep 6, 2023
c8d6d01
Updating data and runDDT.sh script for quick testing
sven-oly Sep 7, 2023
baaf7bd
Update quick locale NodeJS tests
sven-oly Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions executors/node/collator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@
// to the strength.
module.exports = {

testCollationShort: function(json) {
testCollationShort: function(json, shifted) {

// Global default locale
let testLocale = '';
let testCollOptions = {ignorePunctuation:'true'};
let testLocale = undefined;
// TODO: set locale if provided in the test data.

let testCollOptions = {};
if (shifted) {
testCollOptions = {ignorePunctuation:true};
}

// Set up collator object with optional locale and testOptions.
let coll;
try {
if (testLocale) {
coll = new Intl.Collator(testLocale, testCollOptions);
} else {
coll = new Intl.Collator(testCollOptions);
}
coll = new Intl.Collator(testLocale, testCollOptions);

let d1 = json['string1'];
let d2 = json['string2'];

const compared = coll.compare(d1, d2);
let result = compared<= 0 ? true : false;
let resultString = result ? true : false;
outputLine = {'label':json['label'],
"result": result
}
Expand Down
44 changes: 44 additions & 0 deletions executors/node/collator_nonignorable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// The Collator for nonignorable short tests.
sven-oly marked this conversation as resolved.
Show resolved Hide resolved

// !!! TODO: Collation: determine the sensitivity that corresponds
// to the strength.
module.exports = {

testCollationNonignorableShort: function(json) {

// Global default locale
let testLocale = '';
let testCollOptions = {};

// Set up collator object with optional locale and testOptions.
let coll;
try {
if (testLocale) {
coll = new Intl.Collator(testLocale, testCollOptions);
} else {
coll = new Intl.Collator(testCollOptions);
}
sven-oly marked this conversation as resolved.
Show resolved Hide resolved
let d1 = json['string1'];
let d2 = json['string2'];

const compared = coll.compare(d1, d2);
let result = compared<= 0 ? true : false;
let resultString = result ? true : false;
outputLine = {'label':json['label'],
"result": result
}

if (result != true) {
// Additional info for the comparison
outputLine['compare'] = compared;
}

} catch (error) {
outputLine = {'label': json['label'],
'error_message': error.message,
'error': 'Collator compare failed'
};
}
return outputLine;
}
};
16 changes: 15 additions & 1 deletion executors/node/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

let collator = require('./collator.js')

let collator_nonignorable = require('./collator_nonignorable.js')

let numberformatter = require('./numberformat.js')

let displaynames = require('./displaynames.js')
Expand All @@ -44,6 +46,7 @@ let doLogOutput = 0;
// Test type support. Add new items as they are implemented
const testTypes = {
TestCollShiftShort : Symbol("coll_shift_short"),
TestCollNonignorableShort : Symbol("coll_nonignorable_short"),
TestDecimalFormat : Symbol("decimal_fmt"),
TestNumberFormat : Symbol("number_fmt"),
TestDateTimeFormat : Symbol("datetime_fmtl"),
Expand All @@ -55,6 +58,7 @@ const testTypes = {

const supported_test_types = [
Symbol("coll_shift_short"),
Symbol("coll_nonignorable_short"),
Symbol("decimal_fmt"),
Symbol("number_fmt"),
Symbol("display_names"),
Expand All @@ -63,6 +67,7 @@ const supported_test_types = [
const supported_tests_json = {"supported_tests":
[
"coll_shift_short",
"coll_nonignorable_short",
"decimal_fmt",
"number_fmt",
"display_names",
Expand Down Expand Up @@ -90,6 +95,11 @@ function parseJsonForTestId(parsed) {
if (testId == "coll_shift_short") {
return testTypes.TestCollShiftShort;
}

if (testId == "coll_nonignorable_short"){
return testTypes.TestCollNonignorableShort;
}

if (testId == "decimal_fmt" || testId == "number_fmt") {
return testTypes.TestDecimalFormat;
}
Expand Down Expand Up @@ -167,7 +177,11 @@ rl.on('line', function(line) {
// Handle the string directly to call the correct function.
const test_type = parsedJson["test_type"];
if (test_type == "coll_shift_short") {
outputLine = collator.testCollationShort(parsedJson);
outputLine = collator.testCollationShort(parsedJson, true);
} else
if (test_type == "coll_nonignorable_short") {
// Call without test options;
outputLine = collator.testCollationShort(parsedJson, false);
} else
if (test_type == "decimal_fmt" || test_type == "number_fmt") {
outputLine = numberformatter.testDecimalFormat(parsedJson, doLogInput);
Expand Down
8 changes: 5 additions & 3 deletions executors/rust/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use icu::collator::*;
use icu::locid::locale;

// Function runs comparison using collator
pub fn run_collation_test(json_obj: &Value) -> Result<Value, String> {
pub fn run_collation_test(json_obj: &Value, use_shift: bool ) -> Result<Value, String> {
// TODO: Handle errors of missing values and failures.
let label = &json_obj["label"].as_str().unwrap();
let str1: &str = json_obj["string1"].as_str().unwrap();
Expand All @@ -20,8 +20,10 @@ pub fn run_collation_test(json_obj: &Value) -> Result<Value, String> {
let mut options = CollatorOptions::new();
options.strength = Some(Strength::Tertiary);

// Does this ignore punctuation?
//coll_options.set_alternate_handling(Some(AlternateHandling::Shifted));
// Ignore punctuation only if using shifted test.
if use_shift {
options.alternate_handling = Some(AlternateHandling::Shifted);
}

let collator: Collator =
Collator::try_new_unstable(&data_provider, &locale!("en").into(), options).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion executors/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ fn main() -> io::Result<()> {

// TODO!!! : supported_test_map to call the functions.
let json_result = if test_type == "coll_shift_short" {
run_collation_test(&json_info)
run_collation_test(&json_info, true)
} else if test_type == "coll_nonignorable_short" {
run_collation_test(&json_info, false)
} else if (test_type == "decimal_fmt") || (test_type == "number_fmt") {
run_numberformat_test(&json_info)
} else if (test_type == "display_names") || (test_type == "language_display_name") {
Expand Down
14 changes: 7 additions & 7 deletions generateDataAndRun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,24 @@ echo $?
#ICU73
nvm install 20.1.0
nvm use 20.1.0
python3 testdriver.py --icu_version icu73 --exec node --test_type coll_shift_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu73 --exec node --test_type coll_shift_short coll_nonignorable_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000
echo $?

#ICU72
nvm install 18.14.2
nvm use 18.14.2
python3 testdriver.py --icu_version icu72 --exec node --test_type coll_shift_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu72 --exec node --test_type coll_shift_short coll_nonignorable_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000
echo $?

#ICU71
nvm install 18.7.0
python3 testdriver.py --icu_version icu71 --exec node --test_type coll_shift_short number_fmt --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu71 --exec node --test_type coll_shift_short coll_nonignorable_short number_fmt --file_base ../$TEMP_DIR --per_execution 10000
echo $?

# ICU70
nvm install 14.21.3
nvm use 14.21.3
python3 testdriver.py --icu_version icu70 --exec node --test_type coll_shift_short number_fmt --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu70 --exec node --test_type coll_shift_short coll_nonignorable_short number_fmt --file_base ../$TEMP_DIR --per_execution 10000
echo $?

# ICU69
Expand All @@ -96,9 +96,9 @@ python3 testdriver.py --icu_version icu69 --exec node --test_type coll_shift_sho
echo $?

# ICU4X testing
python3 testdriver.py --icu_version icu71 --exec rust --test_type coll_shift_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu71 --exec rust --test_type coll_shift_short coll_nonignorable_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000

python3 testdriver.py --icu_version icu73 --exec rust --test_type coll_shift_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu73 --exec rust --test_type coll_shift_short coll_nonignorable_short number_fmt lang_names --file_base ../$TEMP_DIR --per_execution 10000
echo $?

# Done with test execution
Expand All @@ -111,7 +111,7 @@ popd
# Verify everything
mkdir -p $TEMP_DIR/testReports
pushd verifier
python3 verifier.py --file_base ../$TEMP_DIR --exec rust node dart_web --test_type coll_shift_short number_fmt lang_names
python3 verifier.py --file_base ../$TEMP_DIR --exec rust node dart_web --test_type coll_shift_short coll_nonignorable_short number_fmt lang_names

#python3 verifier.py --file_base ../$TEMP_DIR --exec dart_web --test_type coll_shift_short
#python3 verifier.py --file_base ../$TEMP_DIR --exec cpp--test_type coll_shift_short number_fmt lang_names
Expand Down
6 changes: 6 additions & 0 deletions testdriver/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def resolveCldr(text):
# TODO: Can this be added to a configuration file?
class testType(Enum):
coll_shift = 'coll_shift_short'
coll_nonignorable_short = 'coll_nonignorable_short'
decimal_fmt = 'decimal_fmt'
datetime_fmt = 'datetime_fmt'
display_names = 'display_names'
Expand All @@ -107,6 +108,11 @@ def def_value():
'coll_verify_shift.json',
CLDRVersion.CLDR41, ICUVersion.ICU71)

testName = 'coll_nonignorable_short'
testDatasets[testName] = DataSet(testType.coll_shift.value,
'coll_nonignorable_short_test.json',
'coll_nonignorable_short_verify.json',
CLDRVersion.CLDR43, ICUVersion.ICU73)
testName = 'coll_shift_67'
testDatasets[testName] = DataSet(testType.coll_shift.value,
'coll_test0816_U67.json',
Expand Down
2 changes: 1 addition & 1 deletion testdriver/ddtargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):
self.parallel_mode = None # For each exec or using N CPUs?
self.exec_mode = 'one_test' # Default. 'multi_test

type_options = ['coll_shift_short', 'decimal_fmt', 'display_names',
type_options = ['coll_shift_short', 'coll_nonignorable_short', 'decimal_fmt', 'display_names',
'number_fmt', 'lang_names', 'ALL']

class DdtArgs():
Expand Down
36 changes: 35 additions & 1 deletion testgen/testdata_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setVersion(self, selected_version):
def saveJsonFile(self, filename, data, indent=None):
output_path = os.path.join(self.icu_version, filename)
output_file = open(output_path, 'w')
json.dump(data, output_file, indent=1)
json.dump(data, output_file, indent=indent)
output_file.close()


Expand Down Expand Up @@ -85,6 +85,34 @@ def processCollationTestData(self):

return True

def processNonIgnorableCollationTestData(self):
# Alternate set of data to COLL_SHIFT_SHORT.
filename = 'CollationTest_NON_IGNORABLE_SHORT.txt'

# Read raw data

rawcolltestdata = readFile(filename, self.icu_version)

if not rawcolltestdata:
return None

test_list = rawcolltestdata.splitlines()
# test_list = rawcolltestdata.splitlines() #OLD

# Get lists of tests and verify info
testdata_object_list, verify_list = generateCollTestDataObjects(test_list)
json_test = {}
json_verify = {}
insert_nonignorable_coll_descr(json_test, json_verify)
json_verify['verifications'] = verify_list
json_test['tests'] = testdata_object_list

# And write the files
self.saveJsonFile('coll_nonignorable_short_test.json', json_test)
self.saveJsonFile('coll_nonignorable_short_verify.json', json_verify)

return True

def processNumberFmtTestData(self):
filename = 'dcfmtest.txt'
rawdcmlfmttestdata = readFile(filename, self.icu_version)
Expand Down Expand Up @@ -514,6 +542,10 @@ def insert_coll_descr(tests_obj, verify_obj):
tests_obj['description'] = 'UCA conformance test. Compare the first data string with the second and with strength = identical level (using S3.10). If the second string is greater than the first string, then stop with an error.'
return

def insert_nonignorable_coll_descr(tests_obj, verify_obj):
verify_obj['Test Scenario'] = tests_obj['Test scenario'] = "coll_nonignorable_short"
tests_obj['description'] = 'UCA conformance test. Compare the first data string with the second and with strength = identical level (using S3.10). If the second string is greater than the first string, then stop with an error.'
return

def languageNameDescr(tests_json, verify_json):
# Adds information to LanguageName tests and verify JSON
Expand Down Expand Up @@ -571,6 +603,8 @@ def main(args):

data_generator.processCollationTestData()

data_generator.processNonIgnorableCollationTestData()

data_generator.processNumberFmtTestData()
data_generator.processLangNameTestData()

Expand Down
10 changes: 6 additions & 4 deletions verifier/summary_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@
{role: 'annotation'}];

// Get all the types of tests available
// Sort output in alpha order by executor and by test_type
const test_types = Object.keys(exec_summary_json);
test_types.sort()
/* Get all the execs */
let tests_by_type_and_exec = {};

// Find all the kinds of executors
let execs = new Set();
let exec_set = new Set();
for (const test_type of test_types) {
const tests = exec_summary_json[test_type];
for (node_version of tests) {
execs.add(node_version['exec']);
exec_set.add(node_version['exec']);
}
}

// TODO: Create header for each executor
const execs = Array.from(exec_set).sort();
let th = table.insertRow();
let td = th.insertCell();
td.innerHTML = "Test Type";
Expand Down Expand Up @@ -111,7 +113,7 @@
0: {color:'#00dd77'}, // Passing
1: {color:'#dd0000'}, // Failing
2: {color:'#ffdd00'}, // Error
3: {color: '#777777'} //
3: {color: '#777777'} //
},
};
// Set up options and links
Expand Down
Loading