2012-08-27 05:49:25 +02:00
|
|
|
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
2014-07-22 01:09:02 +02:00
|
|
|
/*---
|
2014-07-25 00:41:42 +02:00
|
|
|
es5id: 9.1_b
|
2014-07-22 01:09:02 +02:00
|
|
|
description: >
|
|
|
|
Tests that appropriate fallback locales are provided for
|
|
|
|
supported locales.
|
|
|
|
author: Norbert Lindenberg
|
|
|
|
includes: [testIntl.js]
|
|
|
|
---*/
|
2012-08-27 05:49:25 +02:00
|
|
|
|
|
|
|
testWithIntlConstructors(function (Constructor) {
|
2021-06-24 19:37:33 +02:00
|
|
|
// The test is only valid under "lookup" localeMatcher
|
|
|
|
var info = getLocaleSupportInfo(Constructor, {localeMatcher: "lookup"});
|
2019-07-22 11:12:05 +02:00
|
|
|
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.");
|
2012-08-27 05:49:25 +02:00
|
|
|
}
|
2019-07-22 11:12:05 +02:00
|
|
|
|
|
|
|
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.");
|
2012-08-27 05:49:25 +02:00
|
|
|
}
|
2019-07-22 11:12:05 +02:00
|
|
|
}
|
2012-08-27 05:49:25 +02:00
|
|
|
});
|