fallback-locales-are-supported.js (1418B)
1 // Copyright 2012 Mozilla Corporation. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es5id: 9.1_b 6 description: > 7 Tests that appropriate fallback locales are provided for 8 supported locales. 9 author: Norbert Lindenberg 10 includes: [testIntl.js] 11 features: [Array.prototype.includes] 12 ---*/ 13 14 testWithIntlConstructors(function (Constructor) { 15 // The test is only valid under "lookup" localeMatcher 16 var info = getLocaleSupportInfo(Constructor, {localeMatcher: "lookup"}); 17 for (var locale of info.supported) { 18 var match = /^([a-z]{2,3})(-[A-Z][a-z]{3})?(-(?:[A-Z]{2}|[0-9]{3}))?$/.exec(locale); 19 assert.notSameValue(match, null, "Locale " + locale + " is supported, but can't be parsed.") 20 21 var [language, script, region] = match.slice(1); 22 23 if (script !== undefined) { 24 var fallback = language + script; 25 assert(info.supported.includes(fallback) || info.byFallback.includes(fallback), 26 "Locale " + locale + " is supported, but fallback " + fallback + " isn't."); 27 } 28 29 if (region !== undefined) { 30 var fallback = language + region; 31 assert(info.supported.includes(fallback) || info.byFallback.includes(fallback), 32 "Locale " + locale + " is supported, but fallback " + fallback + " isn't."); 33 } 34 } 35 }); 36 37 reportCompare(0, 0);