js/src/tests/test262/intl402/ch11/11.1/11.1.1_1.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:8d61f81da77d
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 an object can't be re-initialized as a NumberFormat.
6 * @author Norbert Lindenberg
7 */
8
9 $INCLUDE("testIntl.js");
10
11 testWithIntlConstructors(function (Constructor) {
12 var obj, error;
13
14 // variant 1: use constructor in a "new" expression
15 obj = new Constructor();
16 try {
17 Intl.NumberFormat.call(obj);
18 } catch (e) {
19 error = e;
20 }
21 if (error === undefined) {
22 $ERROR("Re-initializing object created with \"new\" as NumberFormat was not rejected.");
23 } else if (error.name !== "TypeError") {
24 $ERROR("Re-initializing object created with \"new\" as NumberFormat was rejected with wrong error " + error.name + ".");
25 }
26
27 // variant 2: use constructor as a function
28 obj = Constructor.call({});
29 error = undefined;
30 try {
31 Intl.NumberFormat.call(obj);
32 } catch (e) {
33 error = e;
34 }
35 if (error === undefined) {
36 $ERROR("Re-initializing object created with constructor as function as NumberFormat was not rejected.");
37 } else if (error.name !== "TypeError") {
38 $ERROR("Re-initializing object created with constructor as function as NumberFormat was rejected with wrong error " + error.name + ".");
39 }
40
41 return true;
42 });
43

mercurial