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

Side by Side Diff: test/mjsunit/harmony/computed-property-names-classes.js

Issue 985643003: [es6] Throw TypeError for computed static prototype property name (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Inline BuildThrowStaticPrototype Created 5 years, 9 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 | « src/x64/full-codegen-x64.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 'use strict'; 5 'use strict';
6 6
7 // Flags: --harmony-computed-property-names --harmony-classes 7 // Flags: --harmony-computed-property-names --harmony-classes
8 8
9 9
10 function ID(x) { 10 function ID(x) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 set d(_) { 305 set d(_) {
306 calls++ 306 calls++
307 } 307 }
308 } 308 }
309 new C4().d = 'D'; 309 new C4().d = 'D';
310 assertEquals(1, calls); 310 assertEquals(1, calls);
311 })(); 311 })();
312 312
313 313
314 (function TestPrototype() { 314 (function TestPrototype() {
315 // Normally a static prototype property is not allowed. 315 assertThrows(function() {
316 class C { 316 class C {
317 static ['prototype']() { 317 static ['prototype']() {
318 return 1; 318 return 1;
319 }
319 } 320 }
320 } 321 }, TypeError);
321 assertEquals(1, C.prototype());
322 322
323 class C2 { 323 assertThrows(function() {
324 static get ['prototype']() { 324 class C2 {
325 return 2; 325 static get ['prototype']() {
326 return 2;
327 }
326 } 328 }
327 } 329 }, TypeError);
328 assertEquals(2, C2.prototype);
329 330
330 var calls = 0; 331 assertThrows(function() {
331 class C3 { 332 class C3 {
332 static set ['prototype'](x) { 333 static set ['prototype'](x) {
333 assertEquals(3, x); 334 assertEquals(3, x);
334 calls++; 335 }
335 } 336 }
336 } 337 }, TypeError);
337 C3.prototype = 3;
338 assertEquals(1, calls);
339 338
340 class C4 { 339 assertThrows(function() {
341 static *['prototype']() { 340 class C4 {
342 yield 1; 341 static *['prototype']() {
343 yield 2; 342 yield 1;
343 yield 2;
344 }
344 } 345 }
345 } 346 }, TypeError);
346 var iter = C4.prototype();
347 assertIteratorResult(1, false, iter.next());
348 assertIteratorResult(2, false, iter.next());
349 assertIteratorResult(undefined, true, iter.next());
350 })(); 347 })();
351 348
352 349
350 (function TestPrototypeConcat() {
351 assertThrows(function() {
352 class C {
353 static ['pro' + 'tot' + 'ype']() {
354 return 1;
355 }
356 }
357 }, TypeError);
358
359 assertThrows(function() {
360 class C2 {
361 static get ['pro' + 'tot' + 'ype']() {
362 return 2;
363 }
364 }
365 }, TypeError);
366
367 assertThrows(function() {
368 class C3 {
369 static set ['pro' + 'tot' + 'ype'](x) {
370 assertEquals(3, x);
371 }
372 }
373 }, TypeError);
374
375 assertThrows(function() {
376 class C4 {
377 static *['pro' + 'tot' + 'ype']() {
378 yield 1;
379 yield 2;
380 }
381 }
382 }, TypeError);
383 })();
384
385
353 (function TestConstructor() { 386 (function TestConstructor() {
354 // Normally a constructor property is not allowed. 387 // Normally a constructor property is not allowed.
355 class C { 388 class C {
356 ['constructor']() { 389 ['constructor']() {
357 return 1; 390 return 1;
358 } 391 }
359 } 392 }
360 assertTrue(C !== C.prototype.constructor); 393 assertTrue(C !== C.prototype.constructor);
361 assertEquals(1, new C().constructor()); 394 assertEquals(1, new C().constructor());
362 395
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 class C { 456 class C {
424 get [C]() { return 42; } 457 get [C]() { return 42; }
425 } 458 }
426 }, ReferenceError); 459 }, ReferenceError);
427 assertThrows(function() { 460 assertThrows(function() {
428 class C { 461 class C {
429 set [C](_) { } 462 set [C](_) { }
430 } 463 }
431 }, ReferenceError); 464 }, ReferenceError);
432 })(); 465 })();
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698