Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright 2012 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * @description Tests that non-objects are converted to objects before canonicalization.
6 * @author Norbert Lindenberg
7 */
9 $INCLUDE("testIntl.js");
11 testWithIntlConstructors(function (Constructor) {
12 // undefined is handled separately
14 // null should result in a TypeError
15 var error;
16 try {
17 var supportedForNull = Constructor.supportedLocalesOf(null);
18 } catch (e) {
19 error = e;
20 }
21 if (error === undefined) {
22 $ERROR("Null as locale list was not rejected.");
23 } else if (error.name !== "TypeError") {
24 $ERROR("Null as locale list was rejected with wrong error " + error.name + ".");
25 }
27 // let's use an empty list for comparison
28 var supportedForEmptyList = Constructor.supportedLocalesOf([]);
29 // we don't compare the elements because length should be 0 - let's just verify that
30 if (supportedForEmptyList.length !== 0) {
31 $ERROR("Internal test error: Assumption about length being 0 is invalid.");
32 }
34 // most non-objects will be interpreted as empty lists because a missing length property is interpreted as 0
35 var supportedForNumber = Constructor.supportedLocalesOf(5);
36 if (supportedForNumber.length !== supportedForEmptyList.length) {
37 $ERROR("Supported locales differ between numeric and empty list input.");
38 }
39 var supportedForBoolean = Constructor.supportedLocalesOf(true);
40 if (supportedForBoolean.length !== supportedForEmptyList.length) {
41 $ERROR("Supported locales differ between boolean and empty list input.");
42 }
44 return true;
45 });