js/src/tests/test262/intl402/ch12/12.1/12.1.1_1.js

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:d3cdccb56d65
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 DateTimeFormat.
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.DateTimeFormat.call(obj);
18 } catch (e) {
19 error = e;
20 }
21 if (error === undefined) {
22 $ERROR("Re-initializing object created with \"new\" as DateTimeFormat was not rejected.");
23 } else if (error.name !== "TypeError") {
24 $ERROR("Re-initializing object created with \"new\" as DateTimeFormat 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.DateTimeFormat.call(obj);
32 } catch (e) {
33 error = e;
34 }
35 if (error === undefined) {
36 $ERROR("Re-initializing object created with constructor as function as DateTimeFormat was not rejected.");
37 } else if (error.name !== "TypeError") {
38 $ERROR("Re-initializing object created with constructor as function as DateTimeFormat was rejected with wrong error " + error.name + ".");
39 }
40
41 return true;
42 });
43

mercurial