|
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 * @description Tests that appropriate fallback locales are provided for |
|
6 * supported locales. |
|
7 * @author Norbert Lindenberg |
|
8 */ |
|
9 |
|
10 $INCLUDE("testIntl.js"); |
|
11 |
|
12 testWithIntlConstructors(function (Constructor) { |
|
13 var info = getLocaleSupportInfo(Constructor); |
|
14 var fallback; |
|
15 info.supported.forEach(function (locale) { |
|
16 var pos = locale.lastIndexOf("-"); |
|
17 if (pos !== -1) { |
|
18 fallback = locale.substring(0, pos); |
|
19 if (info.supported.indexOf(fallback) === -1) { |
|
20 $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); |
|
21 } |
|
22 } |
|
23 var match = /([a-z]{2,3})(-[A-Z][a-z]{3})(-[A-Z]{2})/.exec(locale); |
|
24 if (match !== null) { |
|
25 fallback = match[1] + match[3]; |
|
26 if (info.supported.indexOf(fallback) === -1) { |
|
27 $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); |
|
28 } |
|
29 } |
|
30 }); |
|
31 }); |
|
32 |