Debian Codegraph @

js/src/tests/test262/language/expressions/new/S11.2.2_A4_T3.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 If NewExpression or MemberExpression does not implement internal
7 [[Construct]] method, throw TypeError
8 es5id: 11.2.2_A4_T3
9 description: Checking String object case
10 ---*/
11
12 //CHECK#1
13 try {
14 new new String("1");
15 throw new Test262Error('#1: new new String("1") throw TypeError');
16 }
17 catch (e) {
18 if ((e instanceof TypeError) !== true) {
19 throw new Test262Error('#1: new new String("1") throw TypeError');
20 }
21 }
22
23 //CHECK#2
24 try {
25 var x = new String("1");
26 new x;
27 throw new Test262Error('#2: var x = new String("1"); new x throw TypeError');
28 }
29 catch (e) {
30 if ((e instanceof TypeError) !== true) {
31 throw new Test262Error('#2: var x = new String("1"); new x throw TypeError');
32 }
33 }
34
35 //CHECK#3
36 try {
37 var x = new String("1");
38 new x();
39 throw new Test262Error('#3: var x = new String("1"); new x() throw TypeError');
40 }
41 catch (e) {
42 if ((e instanceof TypeError) !== true) {
43 throw new Test262Error('#3: var x = new String("1"); new x() throw TypeError');
44 }
45 }
46
47 reportCompare(0, 0);