mirror of
https://github.com/tc39/test262.git
synced 2025-07-31 01:44:54 +02:00
This test started failing when updating to ICU 64, because ICU supports "zh" and "zh-Hans-CN", but not explicitly also "zh-Hans", which is required for this test to pass. The same kind of error is reproducible with ICU <64 when "Guru" is added to the list of script codes in 'testIntl.js', because ICU supports "pa-Guru-IN", but "pa-IN" isn't explicitly supported, too. So, change this test to also check 'byFallback' to see if a locale is supported. Drive-by change: - Modernise the test to make it more readable how subtags are combined. - Also add "419" to the list of region codes to cover the digit region syntax.
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
es5id: 9.1_b
|
|
description: >
|
|
Tests that appropriate fallback locales are provided for
|
|
supported locales.
|
|
author: Norbert Lindenberg
|
|
includes: [testIntl.js]
|
|
---*/
|
|
|
|
testWithIntlConstructors(function (Constructor) {
|
|
var info = getLocaleSupportInfo(Constructor);
|
|
for (var locale of info.supported) {
|
|
var match = /^([a-z]{2,3})(-[A-Z][a-z]{3})?(-(?:[A-Z]{2}|[0-9]{3}))?$/.exec(locale);
|
|
assert.notSameValue(match, null, "Locale " + locale + " is supported, but can't be parsed.")
|
|
|
|
var [language, script, region] = match.slice(1);
|
|
|
|
if (script !== undefined) {
|
|
var fallback = language + script;
|
|
assert(info.supported.includes(fallback) || info.byFallback.includes(fallback),
|
|
"Locale " + locale + " is supported, but fallback " + fallback + " isn't.");
|
|
}
|
|
|
|
if (region !== undefined) {
|
|
var fallback = language + region;
|
|
assert(info.supported.includes(fallback) || info.byFallback.includes(fallback),
|
|
"Locale " + locale + " is supported, but fallback " + fallback + " isn't.");
|
|
}
|
|
}
|
|
});
|