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 9 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: 15 additions & 4 deletions executors/dart_web/bin/collator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ String testCollationShort(String jsonEncoded) {
} else {
coll = Intl();
}
var d1 = json['string1'];
var d2 = json['string2'];
var d1 = json['s1'];
sven-oly marked this conversation as resolved.
Show resolved Hide resolved
var d2 = json['s2'];

var should_ignore_punctuation = false;
try {
// Check the setting of this options
var ignorePunc = json['ignorePunctuation'];
should_ignore_punctuation = ignorePunc;
} catch (error) {
continue;
}

var collationOptions = CollationOptions(ignorePunctuation: should_ignore_punctuation);

var collationOptions = CollationOptions(ignorePunctuation: true);
var compared = coll.collation(collationOptions).compare(d1, d2);
var result = compared <= 0 ? true : false;
outputLine = {'label': json['label'], "result": result};
Expand All @@ -38,7 +48,8 @@ String testCollationShort(String jsonEncoded) {
outputLine = {
'label': json['label'],
'error_message': error.toString(),
'error': 'Collator compare failed'
'error': 'Collator compare failed',
's1': d1, 's2': d2
};
}
return jsonEncode(outputLine);
Expand Down
8 changes: 7 additions & 1 deletion executors/dart_web/out/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let doLogOutput = 0;
// Test type support. Add new items as they are implemented
const testTypes = {
TestCollShiftShort: Symbol("coll_shift_short"),
TestCollationShort: Symbol("collation_short"),
TestDecimalFormat: Symbol("decimal_fmt"),
TestNumberFormat: Symbol("number_fmt"),
TestDateTimeFormat: Symbol("datetime_fmtl"),
Expand All @@ -50,6 +51,7 @@ const testTypes = {

const supported_test_types = [
Symbol("coll_shift_short"),
Symbol("collation_short"),
Symbol("decimal_fmt"),
Symbol("number_fmt"),
Symbol("display_names"),
Expand All @@ -59,6 +61,7 @@ const supported_tests_json = {
"supported_tests":
[
"coll_shift_short",
"collation_short",
"decimal_fmt",
"number_fmt",
"display_names",
Expand Down Expand Up @@ -87,6 +90,9 @@ function parseJsonForTestId(parsed) {
if (testId == "coll_shift_short") {
return testTypes.TestCollShiftShort;
}
if (testId == "coll_shift_short") {
return testTypes.TestCollationShort;
}
if (testId == "decimal_fmt" || testId == "number_fmt") {
return testTypes.TestDecimalFormat;
}
Expand Down Expand Up @@ -166,7 +172,7 @@ rl.on('line', function (line) {
// testId = parseJsonForTestId(parsedJson);
// Handle the string directly to call the correct function.
const test_type = parsedJson["test_type"];
if (test_type == "coll_shift_short") {
if (test_type == "collation_short") {
outputLine = collator.testCollationShort(parsedJson);
} else {
outputLine = {
Expand Down
35 changes: 21 additions & 14 deletions executors/node/collator.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
// The Collator used for the actual testing.

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

testCollationShort: function(json) {
testCollationShort: function(json, shifted) {
// !!! TODO: remove shifted flag

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

let testCollOptions = {};
if ('ignorePunctuation' in json) {
testCollOptions = {
ignorePunctuation:json['ignorePunction']}
}

// 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);
}
let d1 = json['string1'];
let d2 = json['string2'];
coll = new Intl.Collator(testLocale, testCollOptions);

let d1 = json['s1'];
let d2 = json['s2'];

// Should we check with < or <=?
const compared = coll.compare(d1, d2);
let result = compared<= 0 ? true : false;
let resultString = result ? true : false;
let result_bool = true;
if (compared > 0) {
result_bool = false;
}
outputLine = {'label':json['label'],
"result": result
"result": result_bool,
}

if (result != true) {
Expand Down
18 changes: 17 additions & 1 deletion executors/node/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ let doLogOutput = 0;

// Test type support. Add new items as they are implemented
const testTypes = {
TestCollationShort : Symbol("collation_short"),
TestCollShiftShort : Symbol("coll_shift_short"),
TestCollNonignorableShort : Symbol("coll_nonignorable_short"),
TestDecimalFormat : Symbol("decimal_fmt"),
TestNumberFormat : Symbol("number_fmt"),
TestDateTimeFormat : Symbol("datetime_fmtl"),
Expand All @@ -54,7 +56,9 @@ const testTypes = {
}

const supported_test_types = [
Symbol("collation_short"),
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,17 @@ function parseJsonForTestId(parsed) {
if (testId == "coll_shift_short") {
return testTypes.TestCollShiftShort;
}
if (testId == "collation_short") {
return testTypes.TestCollationShort;
}
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 @@ -166,7 +182,7 @@ rl.on('line', function(line) {
// testId = parseJsonForTestId(parsedJson);
// Handle the string directly to call the correct function.
const test_type = parsedJson["test_type"];
if (test_type == "coll_shift_short") {
if (test_type == "collation_short") {
outputLine = collator.testCollationShort(parsedJson);
} else
if (test_type == "decimal_fmt" || test_type == "number_fmt") {
Expand Down
13 changes: 9 additions & 4 deletions executors/rust/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ use icu::locid::locale;
pub fn run_collation_test(json_obj: &Value) -> 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();
let str2: &str = json_obj["string2"].as_str().unwrap();
let ignore_punctuation : &Option<bool> = &json_obj["ignorePunctuation"].as_bool();
let str1: &str = json_obj["s1"].as_str().unwrap();
let str2: &str = json_obj["s2"].as_str().unwrap();

let data_provider = icu_testdata::unstable();

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 let Some(ip) = ignore_punctuation {
if *ip {
options.alternate_handling = Some(AlternateHandling::Shifted);
}
}

let collator: Collator =
Collator::try_new_unstable(&data_provider, &locale!("en").into(), options).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion executors/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn main() -> io::Result<()> {
let label: &str = json_info["label"].as_str().unwrap();

// TODO!!! : supported_test_map to call the functions.
let json_result = if test_type == "coll_shift_short" {
let json_result = if test_type == "collation_short" {
run_collation_test(&json_info)
} else if (test_type == "decimal_fmt") || (test_type == "number_fmt") {
run_numberformat_test(&json_info)
Expand Down
18 changes: 9 additions & 9 deletions generateDataAndRun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,42 +63,42 @@ source "$HOME/.nvm/nvm.sh"
#Dart ICU73
nvm install 20.1.0
nvm use 20.1.0
python3 testdriver.py --icu_version icu73 --exec dart_web --test_type coll_shift_short --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu73 --exec dart_web --test_type collation_short --file_base ../$TEMP_DIR --per_execution 10000
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 collation_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 collation_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 collation_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 collation_short number_fmt --file_base ../$TEMP_DIR --per_execution 10000
echo $?

# ICU69
nvm install 14.18.3
nvm use 14.18.3
python3 testdriver.py --icu_version icu69 --exec node --test_type coll_shift_short number_fmt --file_base ../$TEMP_DIR --per_execution 10000
python3 testdriver.py --icu_version icu69 --exec node --test_type collation_short number_fmt --file_base ../$TEMP_DIR --per_execution 10000
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 collation_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 collation_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 collation_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
16 changes: 5 additions & 11 deletions testdriver/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def resolveCldr(text):

# TODO: Can this be added to a configuration file?
class testType(Enum):
coll_shift = 'coll_shift_short'
collation_short = 'collation_short'
decimal_fmt = 'decimal_fmt'
datetime_fmt = 'datetime_fmt'
display_names = 'display_names'
Expand All @@ -101,16 +101,10 @@ def def_value():
# Initialize dictionary of data organized by test type
testDatasets = defaultdict(def_value)

testName = 'coll_shift_short'
testDatasets[testName] = DataSet(testType.coll_shift.value,
'coll_test_shift.json',
'coll_verify_shift.json',
CLDRVersion.CLDR41, ICUVersion.ICU71)

testName = 'coll_shift_67'
testDatasets[testName] = DataSet(testType.coll_shift.value,
'coll_test0816_U67.json',
None,
testName = 'collation_short'
testDatasets[testName] = DataSet(testType.collation_short.value,
'collation_test.json',
'collation_verify.json',
CLDRVersion.CLDR41, ICUVersion.ICU71)

testName = 'decimal_fmt'
Expand Down
12 changes: 6 additions & 6 deletions testdriver/ddtargs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Process command line arguments for running DDT

# Args expected with examples
# test_type: coll_shift, decimal_fmt, etc.
# test_type: collation_short, decimal_fmt, etc.
# exec: node, rust, cpp, java, custom
# cldr_version: 41
# icu_version: 71.1
Expand Down 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 = ['collation_short', 'decimal_fmt', 'display_names',
'number_fmt', 'lang_names', 'ALL']

class DdtArgs():
Expand Down Expand Up @@ -142,12 +142,12 @@ def setCommonArgs(parser):

def argsTestData():
tests = [
['--test_type', 'coll_shift_short'],
['--test_type', 'coll_shift_short', '-t', 'decimal_fmt'],
['--test_type', 'coll_shift_short', '--test_type', 'decimal_fmt', 'number_fmt', 'display_names',
['--test_type', 'collation_short'],
['--test_type', 'collation_short', '-t', 'decimal_fmt'],
['--test_type', 'collation_short', '--test_type', 'decimal_fmt', 'number_fmt', 'display_names',
'lang_names'],

['--test', 'coll_shift_short', 'ALL', 'decimal_fmt'],
['--test', 'collation_short', 'ALL', 'decimal_fmt'],

['--test_type', 'ALL'],
'--type ALL decimal_fmt --exec a b c d'.split(),
Expand Down
Loading
Loading