Debian Codegraph @

js/src/tests/test262/language/statements/class/definition/this-access-restriction.js

raw
1 // Copyright (C) 2014 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 14.5
5 description: >
6 class this access restriction
7 ---*/
8 class Base {}
9 (function() {
10 class C extends Base {
11 constructor() {
12 var y;
13 super();
14 }
15 }; new C();
16 }());
17 assert.throws(ReferenceError, function() {
18 class C extends Base {
19 constructor() {
20 super(this.x);
21 }
22 }; new C();
23 });
24 assert.throws(ReferenceError, function() {
25 class C extends Base {
26 constructor() {
27 super(this);
28 }
29 }; new C();
30 });
31 assert.throws(ReferenceError, function() {
32 class C extends Base {
33 constructor() {
34 super.method();
35 super(this);
36 }
37 }; new C();
38 });
39 assert.throws(ReferenceError, function() {
40 class C extends Base {
41 constructor() {
42 super(super.method());
43 }
44 }; new C();
45 });
46 assert.throws(ReferenceError, function() {
47 class C extends Base {
48 constructor() {
49 super(super());
50 }
51 }; new C();
52 });
53 assert.throws(ReferenceError, function() {
54 class C extends Base {
55 constructor() {
56 super(1, 2, Object.getPrototypeOf(this));
57 }
58 }; new C();
59 });
60 (function() {
61 class C extends Base {
62 constructor() {
63 { super(1, 2); }
64 }
65 }; new C();
66 }());
67 (function() {
68 class C extends Base {
69 constructor() {
70 if (1) super();
71 }
72 }; new C();
73 }());
74
75 class C1 extends Object {
76 constructor() {
77 'use strict';
78 super();
79 }
80 };
81 new C1();
82
83 class C2 extends Object {
84 constructor() {
85 ; 'use strict';;;;;
86 super();
87 }
88 };
89 new C2();
90
91 class C3 extends Object {
92 constructor() {
93 ; 'use strict';;;;;
94 // This is a comment.
95 super();
96 }
97 };
98 new C3();
99
100 reportCompare(0, 0);