OLD | NEW |
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 --harmony-spread-arrays | 7 // Flags: --harmony-destructuring --harmony-spread-arrays |
8 | 8 |
9 'use strict'; | 9 'use strict'; |
10 | 10 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 function* g() {'use strong'} | 269 function* g() {'use strong'} |
270 assertStrongGenerator(g); | 270 assertStrongGenerator(g); |
271 assertStrongGenerator(function*(){'use strong'}); | 271 assertStrongGenerator(function*(){'use strong'}); |
272 assertStrongGenerator(function* g(){'use strong'}); | 272 assertStrongGenerator(function* g(){'use strong'}); |
273 assertStrongGenerator({*m(){'use strong'}}.m); | 273 assertStrongGenerator({*m(){'use strong'}}.m); |
274 assertStrongGenerator((class {static *m(){'use strong'}}).m); | 274 assertStrongGenerator((class {static *m(){'use strong'}}).m); |
275 assertStrongGenerator((new class {*m(){'use strong'}}).m); | 275 assertStrongGenerator((new class {*m(){'use strong'}}).m); |
276 })(); | 276 })(); |
277 | 277 |
278 (function WeakClassLiterals() { | |
279 function assertWeakClass(x) { | |
280 assertFalse(%IsStrong(x)); | |
281 assertFalse(%IsStrong(x.prototype)); | |
282 assertFalse(%IsStrong(new x)); | |
283 } | |
284 class C {}; | |
285 class D extends C {}; | |
286 class E extends Object {}; | |
287 // class F extends null {}; | |
288 assertWeakClass(C); | |
289 assertWeakClass(D); | |
290 assertWeakClass(E); | |
291 // assertWeakClass(F); | |
292 assertWeakClass(class {}); | |
293 assertWeakClass(class extends Object {}); | |
294 // assertWeakClass(class extends null {}); | |
295 assertWeakClass(class extends C {}); | |
296 assertWeakClass(class extends class {} {}); | |
297 assertWeakClass(class C {}); | |
298 assertWeakClass(class D extends Object {}); | |
299 // assertWeakClass(class D extends null {}); | |
300 assertWeakClass(class D extends C {}); | |
301 assertWeakClass(class D extends class {} {}); | |
302 })(); | |
303 | |
304 (function StrongClassLiterals() { | |
305 'use strong'; | |
306 function assertStrongClass(x) { | |
307 assertTrue(%IsStrong(x)); | |
308 assertTrue(%IsStrong(x.prototype)); | |
309 // TODO(rossberg): strongify class instance | |
310 // assertTrue(%IsStrong(new x)); | |
311 } | |
312 class C {}; | |
313 class D extends C {}; | |
314 class E extends Object {}; | |
315 const W = (1, eval)(() => {'use strict'; return class {}})(); | |
316 class G extends W {}; | |
317 assertStrongClass(C); | |
318 assertStrongClass(D); | |
319 assertStrongClass(E); | |
320 assertStrongClass(G); | |
321 assertStrongClass(class {}); | |
322 assertStrongClass(class extends Object {}); | |
323 assertStrongClass(class extends C {}); | |
324 assertStrongClass(class extends W {}); | |
325 assertStrongClass(class extends class {} {}); | |
326 assertStrongClass(class C {}); | |
327 assertStrongClass(class D extends Object {}); | |
328 assertStrongClass(class D extends C {}); | |
329 assertStrongClass(class D extends W {}); | |
330 assertStrongClass(class D extends class {} {}); | |
331 })(); | |
332 | |
333 (function WeakRegExpLiterals() { | 278 (function WeakRegExpLiterals() { |
334 function assertWeakRegExp(x) { | 279 function assertWeakRegExp(x) { |
335 assertFalse(%IsStrong(x)); | 280 assertFalse(%IsStrong(x)); |
336 } | 281 } |
337 assertWeakRegExp(/abc/); | 282 assertWeakRegExp(/abc/); |
338 })(); | 283 })(); |
339 | 284 |
340 (function StrongRegExpLiterals() { | 285 (function StrongRegExpLiterals() { |
341 'use strong'; | 286 'use strong'; |
342 function assertStrongRegExp(x) { | 287 function assertStrongRegExp(x) { |
343 // TODO(rossberg): strongify regexps | 288 // TODO(rossberg): strongify regexps |
344 // assertTrue(%IsStrong(x)); | 289 // assertTrue(%IsStrong(x)); |
345 } | 290 } |
346 assertStrongRegExp(/abc/); | 291 assertStrongRegExp(/abc/); |
347 })(); | 292 })(); |
OLD | NEW |