|
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.DateTimeFormat has a supportedLocalesOf |
|
6 * property, and it works as planned. |
|
7 * @author: Roozbeh Pournader |
|
8 */ |
|
9 |
|
10 var defaultLocale = new Intl.DateTimeFormat().resolvedOptions().locale; |
|
11 var notSupported = 'zxx'; // "no linguistic content" |
|
12 var requestedLocales = [defaultLocale, notSupported]; |
|
13 |
|
14 var supportedLocales; |
|
15 |
|
16 if (!Intl.DateTimeFormat.hasOwnProperty('supportedLocalesOf')) { |
|
17 $ERROR("Intl.DateTimeFormat doesn't have a supportedLocalesOf property."); |
|
18 } |
|
19 |
|
20 supportedLocales = Intl.DateTimeFormat.supportedLocalesOf(requestedLocales); |
|
21 if (supportedLocales.length !== 1) { |
|
22 $ERROR('The length of supported locales list is not 1.'); |
|
23 } |
|
24 |
|
25 if (supportedLocales[0] !== defaultLocale) { |
|
26 $ERROR('The default locale is not returned in the supported list.'); |
|
27 } |
|
28 |