Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | // Copyright 2012 Mozilla Corporation. All rights reserved. |
michael@0 | 2 | // This code is governed by the BSD license found in the LICENSE file. |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * @description Tests that locales that are reported by resolvedOptions |
michael@0 | 6 | * are also reported by supportedLocalesOf. |
michael@0 | 7 | * @author Norbert Lindenberg |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | $INCLUDE("testIntl.js"); |
michael@0 | 11 | |
michael@0 | 12 | testWithIntlConstructors(function (Constructor) { |
michael@0 | 13 | var info = getLocaleSupportInfo(Constructor); |
michael@0 | 14 | // this test should work equally for both matching algorithms |
michael@0 | 15 | ["lookup", "best fit"].forEach(function (matcher) { |
michael@0 | 16 | var supportedByConstructor = info.supported.concat(info.byFallback); |
michael@0 | 17 | var supported = Constructor.supportedLocalesOf(supportedByConstructor, |
michael@0 | 18 | {localeMatcher: matcher}); |
michael@0 | 19 | // we could check the length first, but it's probably more interesting which locales are missing |
michael@0 | 20 | var i = 0; |
michael@0 | 21 | var limit = Math.min(supportedByConstructor.length, supported.length); |
michael@0 | 22 | while (i < limit && supportedByConstructor[i] === supported[i]) { |
michael@0 | 23 | i++; |
michael@0 | 24 | } |
michael@0 | 25 | if (i < supportedByConstructor.length) { |
michael@0 | 26 | $ERROR("Locale " + supportedByConstructor[i] + |
michael@0 | 27 | " is returned by resolvedOptions but not by supportedLocalesOf."); |
michael@0 | 28 | } else if (i < supported.length) { |
michael@0 | 29 | $ERROR("Locale " + supported[i] + |
michael@0 | 30 | " is returned by supportedLocalesOf but not by resolvedOptions."); |
michael@0 | 31 | } |
michael@0 | 32 | }); |
michael@0 | 33 | |
michael@0 | 34 | // this test is only valid for lookup - best fit may find additional locales supported |
michael@0 | 35 | var unsupportedByConstructor = info.unsupported; |
michael@0 | 36 | var supported = Constructor.supportedLocalesOf(unsupportedByConstructor, |
michael@0 | 37 | {localeMatcher: "lookup"}); |
michael@0 | 38 | if (supported.length > 0) { |
michael@0 | 39 | $ERROR("Locale " + supported[0] + |
michael@0 | 40 | " is returned by supportedLocalesOf but not by resolvedOptions."); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | return true; |
michael@0 | 44 | }); |
michael@0 | 45 |