Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: test/mjsunit/strong/literals.js

Issue 1152093003: [strong] create strong array literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-unboxed-doubles.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --strong-mode --allow-natives-syntax 5 // Flags: --strong-mode --allow-natives-syntax
6 // Flags: --harmony-arrow-functions --harmony-rest-parameters 6 // Flags: --harmony-arrow-functions --harmony-rest-parameters
7 // Flags: --harmony-destructuring 7 // Flags: --harmony-destructuring --harmony-spread-arrays
8 8
9 'use strict'; 9 'use strict';
10 10
11 let GeneratorFunctionPrototype = (function*(){}).__proto__;
12
13 function assertStrongObject(o) {
14 assertTrue(%IsStrong(o));
15 assertSame(Object.prototype, o.__proto__);
16 }
17
18 function assertStrongArray(a) {
19 assertTrue(%IsStrong(a));
20 assertSame(Array.prototype, a.__proto__);
21 }
22
23 function assertStrongFunction(f) {
24 assertTrue(%IsStrong(f));
25 assertSame(Function.prototype, f.__proto__);
26 }
27
28 function assertStrongGenerator(g) {
29 assertTrue(%IsStrong(g));
30 assertSame(GeneratorFunctionPrototype, g.__proto__);
31 }
32
33 (function WeakObjectLiterals() { 11 (function WeakObjectLiterals() {
34 assertTrue(!%IsStrong({})); 12 function assertWeakObject(x) {
35 assertTrue(!%IsStrong({a: 0, b: 0})); 13 assertFalse(%IsStrong(x));
36 assertTrue(!%IsStrong({a: [], b: {}})); 14 assertSame(Object.prototype, Object.getPrototypeOf(x));
37 assertTrue(!%IsStrong({a: [], b: {}}.a)); 15 }
38 assertTrue(!%IsStrong({a: [], b: {}}.b)); 16 assertWeakObject({});
39 assertTrue(!%IsStrong({a: {b: {c: {}}}}.a)); 17 assertWeakObject({a: 0, b: 0});
40 assertTrue(!%IsStrong({a: {b: {c: {}}}}.a.b)); 18 assertWeakObject({a: [], b: {}});
41 assertTrue(!%IsStrong({a: {b: {c: {}}}}.a.b.c)); 19 assertWeakObject({a: [], b: {}}.b);
42 assertTrue(!%IsStrong({f: function(){}})); 20 assertWeakObject({a: {b: {c: {}}}}.a);
43 assertTrue(!%IsStrong(Realm.eval(Realm.current(), 21 assertWeakObject({a: {b: {c: {}}}}.a.b);
44 "({f: function(){}})"))); 22 assertWeakObject({a: {b: {c: {}}}}.a.b.c);
23 assertWeakObject([[1], {}, [[3]]][1]);
24 assertWeakObject({f: function(){}});
25 assertWeakObject(
26 Realm.eval(Realm.current(), "({f: function(){}})"));
45 })(); 27 })();
46 28
47 (function StrongObjectLiterals() { 29 (function StrongObjectLiterals() {
48 'use strong'; 30 'use strong';
31 function assertStrongObject(x) {
32 assertTrue(%IsStrong(x));
33 assertSame(Object.prototype, Object.getPrototypeOf(x));
34 }
49 assertStrongObject({}); 35 assertStrongObject({});
50 assertStrongObject({a: 0, b: 0}); 36 assertStrongObject({a: 0, b: 0});
51 assertStrongObject({a: [], b: {}}); 37 assertStrongObject({a: [], b: {}});
52 assertStrongArray({a: [], b: {}}.a);
53 assertStrongObject({a: [], b: {}}.b); 38 assertStrongObject({a: [], b: {}}.b);
54 assertStrongObject({a: {b: {c: {}}}}.a); 39 assertStrongObject({a: {b: {c: {}}}}.a);
55 assertStrongObject({a: {b: {c: {}}}}.a.b); 40 assertStrongObject({a: {b: {c: {}}}}.a.b);
56 assertStrongObject({a: {b: {c: {}}}}.a.b.c); 41 assertStrongObject({a: {b: {c: {}}}}.a.b.c);
57 // Maps for literals with too many properties are not cached. 42 // Maps for literals with too many properties are not cached.
58 assertStrongObject({ 43 assertStrongObject({
59 x001: 0, x002: 0, x003: 0, x004: 0, x005: 0, 44 x001: 0, x002: 0, x003: 0, x004: 0, x005: 0,
60 x006: 0, x007: 0, x008: 0, x009: 0, x010: 0, 45 x006: 0, x007: 0, x008: 0, x009: 0, x010: 0,
61 x011: 0, x012: 0, x013: 0, x014: 0, x015: 0, 46 x011: 0, x012: 0, x013: 0, x014: 0, x015: 0,
62 x016: 0, x017: 0, x018: 0, x019: 0, x020: 0, 47 x016: 0, x017: 0, x018: 0, x019: 0, x020: 0,
(...skipping 27 matching lines...) Expand all
90 x156: 0, x157: 0, x158: 0, x159: 0, x160: 0, 75 x156: 0, x157: 0, x158: 0, x159: 0, x160: 0,
91 x161: 0, x162: 0, x163: 0, x164: 0, x165: 0, 76 x161: 0, x162: 0, x163: 0, x164: 0, x165: 0,
92 x166: 0, x167: 0, x168: 0, x169: 0, x170: 0, 77 x166: 0, x167: 0, x168: 0, x169: 0, x170: 0,
93 x171: 0, x172: 0, x173: 0, x174: 0, x175: 0, 78 x171: 0, x172: 0, x173: 0, x174: 0, x175: 0,
94 x176: 0, x177: 0, x178: 0, x179: 0, x180: 0, 79 x176: 0, x177: 0, x178: 0, x179: 0, x180: 0,
95 x181: 0, x182: 0, x183: 0, x184: 0, x185: 0, 80 x181: 0, x182: 0, x183: 0, x184: 0, x185: 0,
96 x186: 0, x187: 0, x188: 0, x189: 0, x190: 0, 81 x186: 0, x187: 0, x188: 0, x189: 0, x190: 0,
97 x191: 0, x192: 0, x193: 0, x194: 0, x195: 0, 82 x191: 0, x192: 0, x193: 0, x194: 0, x195: 0,
98 x196: 0, x197: 0, x198: 0, x199: 0, x200: 0, 83 x196: 0, x197: 0, x198: 0, x199: 0, x200: 0,
99 }); 84 });
85 assertStrongObject([[1], {}, [[3]]][1]);
100 assertStrongObject({[Date() + ""]: 0, [Symbol()]: 0}); 86 assertStrongObject({[Date() + ""]: 0, [Symbol()]: 0});
101 assertStrongObject({m() { super.m() }}); 87 assertStrongObject({m() { super.m() }});
88 assertTrue(%IsStrong({__proto__: {}, get a() {}, set b(x) {}}));
102 // Object literals with constant functions are treated specially, 89 // Object literals with constant functions are treated specially,
103 // but currently only on the toplevel (using Realm.eval to emulate that). 90 // but currently only on the toplevel (using Realm.eval to emulate that).
104 assertStrongObject({f: function(){}}); 91 assertStrongObject({f: function(){}});
105 assertStrongObject(Realm.eval(Realm.current(), 92 assertStrongObject(
106 "'use strong'; ({f: function(){}})")); 93 Realm.eval(Realm.current(), "'use strong'; ({f: function(){}})"));
107 assertTrue(%IsStrong({__proto__: {}, get a() {}, set b(x) {}}));
108 })(); 94 })();
109 95
110 (function WeakArrayLiterals(...args) { 96 (function WeakArrayLiterals(...args) {
97 function assertWeakArray(x) {
98 assertFalse(%IsStrong(x));
99 assertSame(Array.prototype, Object.getPrototypeOf(x));
100 }
111 let [...r] = []; 101 let [...r] = [];
112 assertTrue(!%IsStrong(args)); 102 assertWeakArray(args);
113 assertTrue(!%IsStrong(r)); 103 assertWeakArray(r);
114 assertTrue(!%IsStrong([])); 104 assertWeakArray([]);
115 assertTrue(!%IsStrong([1, 2, 3])); 105 assertWeakArray([1, 2, 3]);
116 assertTrue(!%IsStrong([[[]]])); 106 assertWeakArray([1, 2, ...[3, 4], 5]);
117 assertTrue(!%IsStrong([[1], {}, [[3]]])); 107 assertWeakArray([[[]]]);
118 assertTrue(!%IsStrong([[1], {}, [[3]]][0])); 108 assertWeakArray([[1], {}, [[3]]]);
119 assertTrue(!%IsStrong([[1], {}, [[3]]][1])); 109 assertWeakArray([[1], {}, [[3]]][0]);
120 assertTrue(!%IsStrong([[1], {}, [[3]]][2])); 110 assertWeakArray([[1], {}, [[3]]][2]);
121 assertTrue(!%IsStrong([[1], {}, [[3]]][2][0])); 111 assertWeakArray([[1], {}, [[3]]][2][0]);
112 assertWeakArray({a: [], b: {}}.a);
122 })(); 113 })();
123 114
124 (function StrongArrayLiterals(...args) { 115 (function StrongArrayLiterals(...args) {
125 'use strong'; 116 'use strong';
117 function assertStrongArray(x) {
118 assertTrue(%IsStrong(x));
119 assertSame(Array.prototype, Object.getPrototypeOf(x));
120 }
126 let [...r] = []; 121 let [...r] = [];
127 // TODO(rossberg): teach strongness to FastCloneShallowArrayStub 122 assertStrongArray(args);
128 // assertTrue(%IsStrong(args)); 123 assertStrongArray(r);
129 // assertTrue(%IsStrong(r)); 124 assertStrongArray([]);
130 // assertTrue(%IsStrong([])); 125 assertStrongArray([1, 2, 3]);
131 // assertTrue(%IsStrong([1, 2, 3])); 126 assertStrongArray([1, 2, ...[3, 4], 5]);
132 // assertTrue(%IsStrong([1, 2, ...[3, 4], 5]));
133 assertStrongArray([[[]]]); 127 assertStrongArray([[[]]]);
134 assertStrongArray([[1], {}, [[3]]]); 128 assertStrongArray([[1], {}, [[3]]]);
135 assertStrongArray([[1], {}, [[3]]][0]); 129 assertStrongArray([[1], {}, [[3]]][0]);
136 assertStrongObject([[1], {}, [[3]]][1]);
137 assertStrongArray([[1], {}, [[3]]][2]); 130 assertStrongArray([[1], {}, [[3]]][2]);
138 assertStrongArray([[1], {}, [[3]]][2][0]); 131 assertStrongArray([[1], {}, [[3]]][2][0]);
132 assertStrongArray({a: [], b: {}}.a);
139 })(); 133 })();
140 134
141 (function WeakFunctionLiterals() { 135 (function WeakFunctionLiterals() {
136 function assertWeakFunction(x) {
137 assertFalse(%IsStrong(x));
138 assertFalse(%IsStrong(x.prototype));
139 assertSame(Function.prototype, Object.getPrototypeOf(x));
140 }
142 function f() {} 141 function f() {}
143 assertTrue(!%IsStrong(f)); 142 assertWeakFunction(f);
144 assertTrue(!%IsStrong(function(){})); 143 assertWeakFunction(function(){});
145 assertTrue(!%IsStrong(function f(){})); 144 assertWeakFunction(function f(){});
146 assertTrue(!%IsStrong(() => {})); 145 assertWeakFunction(() => {});
147 assertTrue(!%IsStrong(x => x)); 146 assertWeakFunction(x => x);
148 assertTrue(!%IsStrong({m(){}}.m)); 147 assertWeakFunction({m(){}}.m);
149 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( 148 assertWeakFunction(Object.getOwnPropertyDescriptor(
150 {get a(){}}, 'a').get)); 149 {get a(){}}, 'a').get);
151 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( 150 assertWeakFunction(Object.getOwnPropertyDescriptor(
152 {set a(x){}}, 'a').set)); 151 {set a(x){}}, 'a').set);
153 assertTrue(!%IsStrong((class {static m(){}}).m)); 152 assertWeakFunction((class {static m(){}}).m);
154 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( 153 assertWeakFunction(Object.getOwnPropertyDescriptor(
155 class {static get a(){}}, 'a').get)); 154 class {static get a(){}}, 'a').get);
156 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( 155 assertWeakFunction(Object.getOwnPropertyDescriptor(
157 class {static set a(x){}}, 'a').set)); 156 class {static set a(x){}}, 'a').set);
158 assertTrue(!%IsStrong((new class {m(){}}).m)); 157 assertWeakFunction((new class {m(){}}).m);
159 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( 158 assertWeakFunction(Object.getOwnPropertyDescriptor(
160 (class {get a(){}}).prototype, 'a').get)); 159 (class {get a(){}}).prototype, 'a').get);
161 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( 160 assertWeakFunction(Object.getOwnPropertyDescriptor(
162 (class {set a(x){}}).prototype, 'a').set)); 161 (class {set a(x){}}).prototype, 'a').set);
163 })(); 162 })();
164 163
165 (function StrongFunctionLiterals() { 164 (function StrongFunctionLiterals() {
166 'use strong'; 165 'use strong';
166 function assertStrongFunction(x) {
167 assertTrue(%IsStrong(x));
168 assertFalse('prototype' in x);
169 assertSame(Function.prototype, Object.getPrototypeOf(x));
170 }
167 function f() {} 171 function f() {}
168 assertStrongFunction(f); 172 assertStrongFunction(f);
169 assertStrongFunction(function(){}); 173 assertStrongFunction(function(){});
170 assertStrongFunction(function f(){}); 174 assertStrongFunction(function f(){});
171 assertStrongFunction(() => {}); 175 assertStrongFunction(() => {});
172 assertStrongFunction(x => x); 176 assertStrongFunction(x => x);
173 assertStrongFunction({m(){}}.m); 177 assertStrongFunction({m(){}}.m);
174 assertStrongFunction(Object.getOwnPropertyDescriptor( 178 assertStrongFunction(Object.getOwnPropertyDescriptor(
175 {get a(){}}, 'a').get); 179 {get a(){}}, 'a').get);
176 assertStrongFunction(Object.getOwnPropertyDescriptor( 180 assertStrongFunction(Object.getOwnPropertyDescriptor(
177 {set a(x){}}, 'a').set); 181 {set a(x){}}, 'a').set);
178 assertStrongFunction((class {static m(){}}).m); 182 assertStrongFunction((class {static m(){}}).m);
179 assertStrongFunction(Object.getOwnPropertyDescriptor( 183 assertStrongFunction(Object.getOwnPropertyDescriptor(
180 class {static get a(){}}, 'a').get); 184 class {static get a(){}}, 'a').get);
181 assertStrongFunction(Object.getOwnPropertyDescriptor( 185 assertStrongFunction(Object.getOwnPropertyDescriptor(
182 class {static set a(x){}}, 'a').set); 186 class {static set a(x){}}, 'a').set);
183 assertStrongFunction((new class {m(){}}).m); 187 assertStrongFunction((new class {m(){}}).m);
184 assertStrongFunction(Object.getOwnPropertyDescriptor( 188 assertStrongFunction(Object.getOwnPropertyDescriptor(
185 (class {get a(){}}).prototype, 'a').get); 189 (class {get a(){}}).prototype, 'a').get);
186 assertStrongFunction(Object.getOwnPropertyDescriptor( 190 assertStrongFunction(Object.getOwnPropertyDescriptor(
187 (class {set a(x){}}).prototype, 'a').set); 191 (class {set a(x){}}).prototype, 'a').set);
188 })(); 192 })();
189 193
190 (function SelfStrongFunctionLiterals() { 194 (function SelfStrongFunctionLiterals() {
195 function assertStrongFunction(x) {
196 assertTrue(%IsStrong(x));
197 assertFalse('prototype' in x);
198 assertSame(Function.prototype, Object.getPrototypeOf(x));
199 }
191 function f() {'use strong'} 200 function f() {'use strong'}
192 assertStrongFunction(f); 201 assertStrongFunction(f);
193 assertStrongFunction(function(){'use strong'}); 202 assertStrongFunction(function(){'use strong'});
194 assertStrongFunction(function f(){'use strong'}); 203 assertStrongFunction(function f(){'use strong'});
195 assertStrongFunction(() => {'use strong'}); 204 assertStrongFunction(() => {'use strong'});
196 assertStrongFunction(x => {'use strong'}); 205 assertStrongFunction(x => {'use strong'});
197 assertStrongFunction({m(){'use strong'}}.m); 206 assertStrongFunction({m(){'use strong'}}.m);
198 assertStrongFunction(Object.getOwnPropertyDescriptor( 207 assertStrongFunction(Object.getOwnPropertyDescriptor(
199 {get a(){'use strong'}}, 'a').get); 208 {get a(){'use strong'}}, 'a').get);
200 assertStrongFunction(Object.getOwnPropertyDescriptor( 209 assertStrongFunction(Object.getOwnPropertyDescriptor(
201 {set a(x){'use strong'}}, 'a').set); 210 {set a(x){'use strong'}}, 'a').set);
202 assertStrongFunction((class {static m(){'use strong'}}).m); 211 assertStrongFunction((class {static m(){'use strong'}}).m);
203 assertStrongFunction(Object.getOwnPropertyDescriptor( 212 assertStrongFunction(Object.getOwnPropertyDescriptor(
204 class {static get a(){'use strong'}}, 'a').get); 213 class {static get a(){'use strong'}}, 'a').get);
205 assertStrongFunction(Object.getOwnPropertyDescriptor( 214 assertStrongFunction(Object.getOwnPropertyDescriptor(
206 class {static set a(x){'use strong'}}, 'a').set); 215 class {static set a(x){'use strong'}}, 'a').set);
207 assertStrongFunction((new class {m(){'use strong'}}).m); 216 assertStrongFunction((new class {m(){'use strong'}}).m);
208 assertStrongFunction(Object.getOwnPropertyDescriptor( 217 assertStrongFunction(Object.getOwnPropertyDescriptor(
209 (class {get a(){'use strong'}}).prototype, 'a').get); 218 (class {get a(){'use strong'}}).prototype, 'a').get);
210 assertStrongFunction(Object.getOwnPropertyDescriptor( 219 assertStrongFunction(Object.getOwnPropertyDescriptor(
211 (class {set a(x){'use strong'}}).prototype, 'a').set); 220 (class {set a(x){'use strong'}}).prototype, 'a').set);
212 })(); 221 })();
213 222
223 let GeneratorPrototype = (function*(){}).__proto__;
224
214 (function WeakGeneratorLiterals() { 225 (function WeakGeneratorLiterals() {
226 function assertWeakGenerator(x) {
227 assertFalse(%IsStrong(x));
228 assertFalse(%IsStrong(x.prototype));
229 assertSame(GeneratorPrototype, Object.getPrototypeOf(x));
230 assertFalse(%IsStrong(x()));
231 }
215 function* g() {} 232 function* g() {}
216 assertTrue(!%IsStrong(g)); 233 assertWeakGenerator(g);
217 assertTrue(!%IsStrong(function*(){})); 234 assertWeakGenerator(function*(){});
218 assertTrue(!%IsStrong(function* g(){})); 235 assertWeakGenerator(function* g(){});
219 assertTrue(!%IsStrong({*m(){}}.m)); 236 assertWeakGenerator({*m(){}}.m);
220 assertTrue(!%IsStrong((class {static *m(){}}).m)); 237 assertWeakGenerator((class {static *m(){}}).m);
221 assertTrue(!%IsStrong((new class {*m(){}}).m)); 238 assertWeakGenerator((new class {*m(){}}).m);
222 })(); 239 })();
223 240
224 (function StrongGeneratorLiterals() { 241 (function StrongGeneratorLiterals() {
225 'use strong'; 242 'use strong';
243 function assertStrongGenerator(x) {
244 assertTrue(%IsStrong(x));
245 // TODO(rossberg): strongify generator prototypes
246 // assertTrue(%IsStrong(x.prototype));
247 assertSame(GeneratorPrototype, Object.getPrototypeOf(x));
248 // TODO(rossberg): strongify generator instances
249 // assertTrue(%IsStrong(x()));
250 }
226 function* g() {} 251 function* g() {}
227 assertStrongGenerator(g); 252 assertStrongGenerator(g);
228 assertStrongGenerator(function*(){}); 253 assertStrongGenerator(function*(){});
229 assertStrongGenerator(function* g(){}); 254 assertStrongGenerator(function* g(){});
230 assertStrongGenerator({*m(){}}.m); 255 assertStrongGenerator({*m(){}}.m);
231 assertStrongGenerator((class {static *m(){}}).m); 256 assertStrongGenerator((class {static *m(){}}).m);
232 assertStrongGenerator((new class {*m(){}}).m); 257 assertStrongGenerator((new class {*m(){}}).m);
233 })(); 258 })();
234 259
235 (function SelfStrongGeneratorLiterals() { 260 (function SelfStrongGeneratorLiterals() {
261 function assertStrongGenerator(x) {
262 assertTrue(%IsStrong(x));
263 // TODO(rossberg): strongify generator prototypes
264 // assertTrue(%IsStrong(x.prototype));
265 assertSame(GeneratorPrototype, Object.getPrototypeOf(x));
266 // TODO(rossberg): strongify generator instances
267 // assertTrue(%IsStrong(x()));
268 }
236 function* g() {'use strong'} 269 function* g() {'use strong'}
237 assertStrongGenerator(g); 270 assertStrongGenerator(g);
238 assertStrongGenerator(function*(){'use strong'}); 271 assertStrongGenerator(function*(){'use strong'});
239 assertStrongGenerator(function* g(){'use strong'}); 272 assertStrongGenerator(function* g(){'use strong'});
240 assertStrongGenerator({*m(){'use strong'}}.m); 273 assertStrongGenerator({*m(){'use strong'}}.m);
241 assertStrongGenerator((class {static *m(){'use strong'}}).m); 274 assertStrongGenerator((class {static *m(){'use strong'}}).m);
242 assertStrongGenerator((new class {*m(){'use strong'}}).m); 275 assertStrongGenerator((new class {*m(){'use strong'}}).m);
243 })(); 276 })();
244 277
245 (function WeakClassLiterals() { 278 (function WeakClassLiterals() {
246 function assertWeakClass(C) { 279 function assertWeakClass(x) {
247 assertTrue(!%IsStrong(C)); 280 assertFalse(%IsStrong(x));
248 assertTrue(!%IsStrong(C.prototype)); 281 assertFalse(%IsStrong(x.prototype));
282 assertFalse(%IsStrong(new x));
249 } 283 }
250 class C {}; 284 class C {};
251 class D extends C {}; 285 class D extends C {};
252 class E extends Object {}; 286 class E extends Object {};
253 class F extends null {}; 287 // class F extends null {};
254 const S = (() => {'use strong'; return class {}})(); 288 const S = (() => {'use strong'; return class {}})();
255 class G extends S {}; 289 class G extends S {};
256 assertWeakClass(C); 290 assertWeakClass(C);
257 assertWeakClass(D); 291 assertWeakClass(D);
258 assertWeakClass(E); 292 assertWeakClass(E);
259 assertWeakClass(F); 293 // assertWeakClass(F);
260 assertWeakClass(G); 294 assertWeakClass(G);
261 assertWeakClass(class {}); 295 assertWeakClass(class {});
262 assertWeakClass(class extends Object {}); 296 assertWeakClass(class extends Object {});
263 assertWeakClass(class extends null {}); 297 // assertWeakClass(class extends null {});
264 assertWeakClass(class extends C {}); 298 assertWeakClass(class extends C {});
265 assertWeakClass(class extends S {}); 299 assertWeakClass(class extends S {});
266 assertWeakClass(class extends class {} {}); 300 assertWeakClass(class extends class {} {});
267 assertWeakClass(class C {}); 301 assertWeakClass(class C {});
268 assertWeakClass(class D extends Object {}); 302 assertWeakClass(class D extends Object {});
269 assertWeakClass(class D extends null {}); 303 // assertWeakClass(class D extends null {});
270 assertWeakClass(class D extends C {}); 304 assertWeakClass(class D extends C {});
271 assertWeakClass(class D extends S {}); 305 assertWeakClass(class D extends S {});
272 assertWeakClass(class D extends class {} {}); 306 assertWeakClass(class D extends class {} {});
273 })(); 307 })();
274 308
275 (function StrongClassLiterals() { 309 (function StrongClassLiterals() {
276 'use strong'; 310 'use strong';
277 function assertStrongClass(C) { 311 function assertStrongClass(x) {
278 assertTrue(%IsStrong(C)); 312 assertTrue(%IsStrong(x));
279 // TODO(rossberg): prototype object is not yet strongified 313 // TODO(rossberg): strongify class prototype and instance
280 // assertTrue(%IsStrong(C.prototype)); 314 // assertTrue(%IsStrong(x.prototype));
315 // assertTrue(%IsStrong(new x));
281 } 316 }
282 class C {}; 317 class C {};
283 class D extends C {}; 318 class D extends C {};
284 class E extends Object {}; 319 class E extends Object {};
285 class F extends null {};
286 const W = (1, eval)(() => {'use strict'; return class {}})(); 320 const W = (1, eval)(() => {'use strict'; return class {}})();
287 class G extends W {}; 321 class G extends W {};
288 assertStrongClass(C); 322 assertStrongClass(C);
289 assertStrongClass(D); 323 assertStrongClass(D);
290 assertStrongClass(E); 324 assertStrongClass(E);
291 assertStrongClass(F);
292 assertStrongClass(G); 325 assertStrongClass(G);
293 assertStrongClass(class {}); 326 assertStrongClass(class {});
294 assertStrongClass(class extends Object {}); 327 assertStrongClass(class extends Object {});
295 assertStrongClass(class extends null {});
296 assertStrongClass(class extends C {}); 328 assertStrongClass(class extends C {});
297 assertStrongClass(class extends W {}); 329 assertStrongClass(class extends W {});
298 assertStrongClass(class extends class {} {}); 330 assertStrongClass(class extends class {} {});
299 assertStrongClass(class C {}); 331 assertStrongClass(class C {});
300 assertStrongClass(class D extends Object {}); 332 assertStrongClass(class D extends Object {});
301 assertStrongClass(class D extends null {});
302 assertStrongClass(class D extends C {}); 333 assertStrongClass(class D extends C {});
303 assertStrongClass(class D extends W {}); 334 assertStrongClass(class D extends W {});
304 assertStrongClass(class D extends class {} {}); 335 assertStrongClass(class D extends class {} {});
305 })(); 336 })();
306 337
307 (function WeakRegExpLiterals() { 338 (function WeakRegExpLiterals() {
308 assertTrue(!%IsStrong(/abc/)); 339 function assertWeakRegExp(x) {
340 assertFalse(%IsStrong(x));
341 }
342 assertWeakRegExp(/abc/);
309 })(); 343 })();
310 344
311 (function StrongRegExpLiterals() { 345 (function StrongRegExpLiterals() {
312 'use strong'; 346 'use strong';
313 // TODO(rossberg): implement strong regexp literals 347 function assertStrongRegExp(x) {
314 // assertTrue(%IsStrong(/abc/)); 348 // TODO(rossberg): strongify regexps
349 // assertTrue(%IsStrong(x));
350 }
351 assertStrongRegExp(/abc/);
315 })(); 352 })();
OLDNEW
« no previous file with comments | « test/cctest/test-unboxed-doubles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698