supportedLocalesOf-unicode-extensions-ignored.js (2477B)
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.2.6_4_b 6 description: > 7 Tests that Unicode locale extension sequences do not affect 8 whether a locale is considered supported, but are reported back. 9 author: Norbert Lindenberg 10 includes: [testIntl.js] 11 ---*/ 12 13 testWithIntlConstructors(function (Constructor) { 14 15 // this test should work equally for both matching algorithms 16 ["lookup", "best fit"].forEach(function (matcher) { 17 var opt = {localeMatcher: matcher}; 18 var info = getLocaleSupportInfo(Constructor, opt); 19 var allLocales = info.supported.concat(info.byFallback, info.unsupported); 20 allLocales.forEach(function (locale) { 21 var validExtension = "-u-co-phonebk-nu-latn"; 22 var invalidExtension = "-u-nu-invalid"; 23 var supported1 = Constructor.supportedLocalesOf([locale], opt); 24 var supported2 = Constructor.supportedLocalesOf([locale + validExtension], opt); 25 var supported3 = Constructor.supportedLocalesOf([locale + invalidExtension], opt); 26 if (supported1.length === 1) { 27 assert.sameValue(supported2.length, 1, "#1.1: Presence of Unicode locale extension sequence affects whether locale " + locale + " is considered supported with matcher " + matcher + "."); 28 assert.sameValue(supported3.length, 1, "#1.2: Presence of Unicode locale extension sequence affects whether locale " + locale + " is considered supported with matcher " + matcher + "."); 29 assert.sameValue(supported2[0], locale + validExtension, "#2.1: Unicode locale extension sequence is not correctly returned for locale " + locale + " with matcher " + matcher + "."); 30 assert.sameValue(supported3[0], locale + invalidExtension, "#2.2: Unicode locale extension sequence is not correctly returned for locale " + locale + " with matcher " + matcher + "."); 31 } else { 32 assert.sameValue(supported2.length, 0, "#3.1: Presence of Unicode locale extension sequence affects whether locale " + locale + " is considered supported with matcher " + matcher + "."); 33 assert.sameValue(supported3.length, 0, "#3.2: Presence of Unicode locale extension sequence affects whether locale " + locale + " is considered supported with matcher " + matcher + "."); 34 } 35 }); 36 }); 37 }); 38 39 reportCompare(0, 0);