-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add likely_subtags: data generation, node executor #93
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
44fa926
Add likely_subtags: data generation, node executor
sven-oly 2a21265
Add likely_subtags to node testdriver and to verify
sven-oly f30c7fb
Update characterized failures for option values and locale
sven-oly cde3deb
LikelySubtags: update test generation and Node executor
sven-oly 92cf3f3
Update latest version of nodeJS to 20.5.1
sven-oly 7738596
minimizeFavorRegion moved to 'unsupported'
sven-oly 0ddfdbe
Likely subtags: update test data to consider default values
sven-oly bb56a90
Revert Node version for Dart
sven-oly 3f47f06
Sync regenerate script
sven-oly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
The type of test determines the corresponding test function that then | ||
receives the test case. This includes the type of operation, e.g., | ||
collation, number format, locale matching, etc. | ||
collation, number format, locale matching, likely subtags, etc. | ||
|
||
The data includes parameters needed to specify the function called as well | ||
as the test data passed to the function. | ||
|
@@ -24,6 +24,8 @@ let displaynames = require('./displaynames.js') | |
|
||
let langnames = require('./langnames.js') | ||
|
||
let likely_subtags = require('./likely_subtags.js') | ||
|
||
/** | ||
* TODOs: | ||
* 1. Handle other types of test cases. | ||
|
@@ -38,7 +40,7 @@ let langnames = require('./langnames.js') | |
* Started 28-July-2022, [email protected] | ||
*/ | ||
|
||
let doLogInput = 0; | ||
let doLogInput = 0; // TODO: How to turn this on from command line? | ||
let doLogOutput = 0; | ||
|
||
// Test type support. Add new items as they are implemented | ||
|
@@ -58,7 +60,8 @@ const supported_test_types = [ | |
Symbol("decimal_fmt"), | ||
Symbol("number_fmt"), | ||
Symbol("display_names"), | ||
Symbol("language_display_name") | ||
Symbol("language_display_name"), | ||
Symbol("local_info") | ||
]; | ||
const supported_tests_json = {"supported_tests": | ||
[ | ||
|
@@ -124,12 +127,12 @@ rl.on('line', function(line) { | |
if (line == "#VERSION") { | ||
// JSON output of the test enviroment. | ||
const versionJson = {'platform': 'NodeJS', | ||
'platformVersion': process.version, | ||
'icuVersion': process.versions.icu, | ||
'cldrVersion': process.versions.cldr | ||
}; | ||
'platformVersion': process.version, | ||
'icuVersion': process.versions.icu, | ||
'cldrVersion': process.versions.cldr | ||
}; | ||
|
||
// TODO: Make this more specific JSON info. | ||
// TODO: Make this more specific for JSON info. | ||
lineOut = JSON.stringify(versionJson); | ||
process.stdout.write(lineOut); | ||
} else | ||
|
@@ -147,12 +150,13 @@ rl.on('line', function(line) { | |
try { | ||
parsedJson = JSON.parse(line); | ||
} catch (error) { | ||
outputLine = {'Cannot parse input line': error, | ||
outputLine = {'error': error, | ||
'message': 'Cannot parse input line', | ||
'input_line': line, | ||
"testId": testId}; | ||
|
||
// Send result to stdout for verification | ||
jsonOut = JSON.stringify(outputLine); | ||
const jsonOut = JSON.stringify(outputLine); | ||
if (doLogOutput > 0) { | ||
console.log("## ERROR " + lineId + ' ' + outputLine + ' !!!!!'); | ||
} | ||
|
@@ -163,7 +167,6 @@ rl.on('line', function(line) { | |
console.log("#----- PARSED JSON: " + JSON.stringify(parsedJson)); | ||
} | ||
|
||
// testId = parseJsonForTestId(parsedJson); | ||
// Handle the string directly to call the correct function. | ||
const test_type = parsedJson["test_type"]; | ||
if (test_type == "coll_shift_short") { | ||
|
@@ -177,18 +180,23 @@ rl.on('line', function(line) { | |
} else | ||
if (test_type == "language_display_name") { | ||
outputLine = langnames.testLangNames(parsedJson); | ||
} else | ||
if (test_type == "likely_subtags") { | ||
outputLine = likely_subtags.testLikelySubtags(parsedJson); | ||
} else { | ||
outputLine = {'error': 'unknown test type', 'testId': testId, | ||
'unsupported_test': testId}; | ||
outputLine = {'error': 'unknown test type', | ||
'test_type': test_type, | ||
'unsupported_test': test_type}; | ||
} | ||
|
||
const jsonOut = JSON.stringify(outputLine); | ||
|
||
if ('error' in outputLine) { | ||
// To get the attention of the driver | ||
console.log("#!! ERROR in NODE call: " + JSON.stringify(outputLine)); | ||
console.log("#!! ERROR in NODE call: " + jsonOut); | ||
} | ||
|
||
// Send result to stdout for verification | ||
jsonOut = JSON.stringify(outputLine); | ||
process.stdout.write(jsonOut + '\n'); | ||
if (doLogOutput > 0) { | ||
console.log("##### NODE RETURNS " + lineId + ' ' + jsonOut + ' !!!!!'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Tests Intl Locale for minimize / maximize likely subtags. | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale | ||
|
||
|
||
module.exports = { | ||
testLikelySubtags: function (json) { | ||
const label = json['label']; | ||
const locale = json['locale']; | ||
let test_option; | ||
if (json['option']) { | ||
test_option = json['option']; | ||
} | ||
|
||
let return_json = {'label': label}; | ||
let intl_locale; | ||
try { | ||
intl_locale = new Intl.Locale(locale); | ||
} catch (error) { | ||
/* Something is wrong with the constructor */ | ||
return_json['error'] = 'CONSTRUCTOR: ' + error.message; | ||
return return_json; | ||
} | ||
|
||
try { | ||
let result_locale; | ||
if (test_option === 'maximize') { | ||
result_locale = intl_locale.maximize().baseName; | ||
} else if (test_option === 'minimizeFavorScript' || | ||
test_option === 'minimize') { | ||
result_locale = intl_locale.minimize().baseName; | ||
} else if (test_option === 'minimizeFavorRegion') { | ||
result_locale = intl_locale.minimizeFavorRegion().baseName; | ||
} else { | ||
return_json['error'] = 'Unknown test option = ' + test_option; | ||
} | ||
return_json['result'] = result_locale; | ||
} catch (error) { | ||
return_json['unsupported'] = 'LIKELY_SUBTAGS UNKNOWN ERROR: ' + error.message; | ||
} | ||
return return_json; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: there is no
Intl.Locale.prototype.minizeFavorRegion
; this should be unsupportedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where this is fixed but OK to fix later