| 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.2 |
| 6 |
description: > |
| 7 |
Tests that locales that are reported by resolvedOptions are also |
| 8 |
reported by supportedLocalesOf. |
| 9 |
author: Norbert Lindenberg |
| 10 |
includes: [testIntl.js] |
| 11 |
---*/ |
| 12 |
|
| 13 |
testWithIntlConstructors(function (Constructor) { |
| 14 |
// this test should work equally for both matching algorithms |
| 15 |
["lookup", "best fit"].forEach(function (matcher) { |
| 16 |
var info = getLocaleSupportInfo(Constructor, {localeMatcher: matcher}); |
| 17 |
var supportedByConstructor = info.supported.concat(info.byFallback); |
| 18 |
var supported = Constructor.supportedLocalesOf(supportedByConstructor, |
| 19 |
{localeMatcher: matcher}); |
| 20 |
// we could check the length first, but it's probably more interesting which locales are missing |
| 21 |
var i = 0; |
| 22 |
var limit = Math.min(supportedByConstructor.length, supported.length); |
| 23 |
while (i < limit && supportedByConstructor[i] === supported[i]) { |
| 24 |
i++; |
| 25 |
} |
| 26 |
assert.sameValue(i < supportedByConstructor.length, false, "Locale " + supportedByConstructor[i] + " is returned by resolvedOptions but not by supportedLocalesOf."); |
| 27 |
assert.sameValue(i < supported.length, false, "Locale " + supported[i] + " is returned by supportedLocalesOf but not by resolvedOptions."); |
| 28 |
}); |
| 29 |
|
| 30 |
// this test is only valid for lookup - best fit may find additional locales supported |
| 31 |
var info = getLocaleSupportInfo(Constructor, {localeMatcher: "lookup"}); |
| 32 |
var unsupportedByConstructor = info.unsupported; |
| 33 |
var supported = Constructor.supportedLocalesOf(unsupportedByConstructor, |
| 34 |
{localeMatcher: "lookup"}); |
| 35 |
assert.sameValue(supported.length > 0, false, "Locale " + supported[0] + " is returned by supportedLocalesOf but not by resolvedOptions."); |
| 36 |
}); |
| 37 |
|
| 38 |
reportCompare(0, 0); |