|
1 // Copyright 2012 Google Inc. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * @description Tests that Intl.Collator has a supportedLocalesOf |
|
6 * property, and it works as planned. |
|
7 */ |
|
8 |
|
9 var defaultLocale = new Intl.Collator().resolvedOptions().locale; |
|
10 var notSupported = 'zxx'; // "no linguistic content" |
|
11 var requestedLocales = [defaultLocale, notSupported]; |
|
12 |
|
13 var supportedLocales; |
|
14 |
|
15 if (!Intl.Collator.hasOwnProperty('supportedLocalesOf')) { |
|
16 $ERROR("Intl.Collator doesn't have a supportedLocalesOf property."); |
|
17 } |
|
18 |
|
19 supportedLocales = Intl.Collator.supportedLocalesOf(requestedLocales); |
|
20 if (supportedLocales.length !== 1) { |
|
21 $ERROR('The length of supported locales list is not 1.'); |
|
22 } |
|
23 |
|
24 if (supportedLocales[0] !== defaultLocale) { |
|
25 $ERROR('The default locale is not returned in the supported list.'); |
|
26 } |
|
27 |