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

Side by Side Diff: test/mjsunit/es6/classes-subclass-builtins.js

Issue 1473323003: Add test for Promises subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@in-obj-array-buffer-view
Patch Set: Created 5 years 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 | « no previous file | 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: --allow-natives-syntax --harmony-reflect --harmony-regexp-subclass 5 // Flags: --allow-natives-syntax --harmony-reflect --harmony-regexp-subclass
6 // Flags: --expose-gc 6 // Flags: --expose-gc
7 7
8 "use strict"; 8 "use strict";
9 9
10 10
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 assertPropertiesEqual({done: true, value: undefined}, o.next()); 540 assertPropertiesEqual({done: true, value: undefined}, o.next());
541 541
542 var generator_func1 = new A("return 0;"); 542 var generator_func1 = new A("return 0;");
543 assertTrue(%HaveSameMap(generator_func, generator_func1)); 543 assertTrue(%HaveSameMap(generator_func, generator_func1));
544 544
545 gc(); 545 gc();
546 })(); 546 })();
547 547
548 548
549 (function() { 549 (function() {
550 class A extends Promise {
551 constructor(...args) {
552 assertTrue(%IsConstructCall());
553 super(...args);
554 this.a = 42;
555 this.d = 4.2;
556 this.o = {foo:153};
557 }
558 }
559
560 var o = new A(function(resolve, reject) {
561 resolve("ok");
562 });
563 assertTrue(o instanceof Object);
564 assertTrue(o instanceof Promise);
565 assertTrue(o instanceof A);
566 assertEquals("object", typeof o);
567 checkPrototypeChain(o, [A, Promise, Object]);
568 assertEquals(42, o.a);
569 assertEquals(4.2, o.d);
570 assertEquals(153, o.o.foo);
571 o.then(
572 function(val) { assertEquals("ok", val); },
573 function(reason) { assertUnreachable(); })
574 .catch(function(reason) { %AbortJS("catch handler called: " + reason); });
575
576 var o1 = new A(function(resolve, reject) {
577 reject("fail");
578 });
579 o1.then(
580 function(val) { assertUnreachable(); },
581 function(reason) { assertEquals("fail", reason); })
582 .catch(function(reason) { %AbortJS("catch handler called: " + reason); });
583 assertTrue(%HaveSameMap(o, o1));
584
585 gc();
586 })();
587
588
589 (function() {
550 class A extends Boolean { 590 class A extends Boolean {
551 constructor() { 591 constructor() {
552 assertTrue(%IsConstructCall()); 592 assertTrue(%IsConstructCall());
553 super(true); 593 super(true);
554 this.a00 = 0 594 this.a00 = 0
555 this.a01 = 0 595 this.a01 = 0
556 this.a02 = 0 596 this.a02 = 0
557 this.a03 = 0 597 this.a03 = 0
558 this.a04 = 0 598 this.a04 = 0
559 this.a05 = 0 599 this.a05 = 0
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 821
782 Object.defineProperty(pattern, Symbol.match, { 822 Object.defineProperty(pattern, Symbol.match, {
783 get() { log.push("match"); f.prototype = p2; return false; }}); 823 get() { log.push("match"); f.prototype = p2; return false; }});
784 824
785 var o = Reflect.construct(RegExp, [pattern], f); 825 var o = Reflect.construct(RegExp, [pattern], f);
786 assertEquals(["match", "tostring"], log); 826 assertEquals(["match", "tostring"], log);
787 assertEquals(/biep/, o); 827 assertEquals(/biep/, o);
788 assertTrue(o.__proto__ === p2); 828 assertTrue(o.__proto__ === p2);
789 assertTrue(f.prototype === p3); 829 assertTrue(f.prototype === p3);
790 })(); 830 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698