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

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

Issue 1448933002: Introduce a BuiltinsConstructStub that sets up new.target and does a [[call]] per ES6 9.3.2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/builtins-x64.cc ('k') | test/mjsunit/es6/regexp-constructor.js » ('j') | 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 5 // Flags: --allow-natives-syntax --harmony-reflect --harmony-regexp-subclass
6 6
7 "use strict"; 7 "use strict";
8 8
9 9
10 function checkPrototypeChain(object, constructors) { 10 function checkPrototypeChain(object, constructors) {
11 var proto = object.__proto__; 11 var proto = object.__proto__;
12 for (var i = 0; i < constructors.length; i++) { 12 for (var i = 0; i < constructors.length; i++) {
13 assertEquals(constructors[i].prototype, proto); 13 assertEquals(constructors[i].prototype, proto);
14 assertEquals(constructors[i], proto.constructor); 14 assertEquals(constructors[i], proto.constructor);
15 proto = proto.__proto__; 15 proto = proto.__proto__;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 (function() { 597 (function() {
598 class A extends null {} 598 class A extends null {}
599 assertThrows("new A"); 599 assertThrows("new A");
600 })(); 600 })();
601 601
602 602
603 (function() { 603 (function() {
604 class A extends Symbol {} 604 class A extends Symbol {}
605 assertThrows("new A"); 605 assertThrows("new A");
606 })(); 606 })();
607
608
609 (function() {
610 function f() {}
611
612 var p = f.prototype;
613 var p2 = {};
614 var o = Reflect.construct(
615 Number, [{valueOf() { f.prototype=p2; return 10; }}], f);
616
617 assertTrue(o.__proto__ === f.prototype);
618 assertTrue(p2 === f.prototype);
619 assertFalse(p === o.__proto__);
620 assertEquals(10, Number.prototype.valueOf.call(o));
621 })();
622
623
624 (function() {
625 function f() {}
626
627 var p = f.prototype;
628 var p2 = {};
629 var o = Reflect.construct(
630 String, [{toString() { f.prototype=p2; return "biep"; }}], f);
631
632 assertTrue(o.__proto__ === f.prototype);
633 assertTrue(p2 === o.__proto__);
634 assertFalse(p === o.__proto__);
635 assertEquals("biep", String.prototype.toString.call(o));
636 })();
637
638
639 (function() {
640 function f() {}
641
642 var p = f.prototype;
643 var p2 = {};
644 var o = Reflect.construct(
645 Date, [{valueOf() { f.prototype=p2; return 1447836899614; }}], f);
646
647 assertTrue(o.__proto__ === f.prototype);
648 assertTrue(p2 === f.prototype);
649 assertFalse(p === o.__proto__);
650 assertEquals(new Date(1447836899614).toString(),
651 Date.prototype.toString.call(o));
652 })();
653
654
655 (function() {
656 function f() {}
657
658 var p = f.prototype;
659 var p2 = {};
660 var o = Reflect.construct(
661 Date, [2015, {valueOf() { f.prototype=p2; return 10; }}], f);
662
663 assertTrue(o.__proto__ === f.prototype);
664 assertTrue(p2 === f.prototype);
665 assertFalse(p === o.__proto__);
666 assertEquals(new Date(2015, 10).getYear(), Date.prototype.getYear.call(o));
667 assertEquals(new Date(2015, 10).getMonth(), Date.prototype.getMonth.call(o));
668 })();
669
670
671 (function() {
672 function f() {}
673
674 var p = f.prototype;
675 var p2 = {};
676 var o = Reflect.construct(
677 DataView, [new ArrayBuffer(100),
678 {valueOf(){ f.prototype=p2; return 5; }}], f);
679
680 var byteOffset = Object.getOwnPropertyDescriptor(
681 DataView.prototype, "byteOffset").get;
682 var byteLength = Object.getOwnPropertyDescriptor(
683 DataView.prototype, "byteLength").get;
684
685 assertTrue(o.__proto__ === f.prototype);
686 assertTrue(p2 === f.prototype);
687 assertFalse(p === o.__proto__);
688 assertEquals(5, byteOffset.call(o));
689 assertEquals(95, byteLength.call(o));
690 })();
691
692
693 (function() {
694 function f() {}
695
696 var p = f.prototype;
697 var p2 = {};
698 var o = Reflect.construct(
699 DataView, [new ArrayBuffer(100),
700 30, {valueOf() { f.prototype=p2; return 5; }}], f);
701
702 var byteOffset = Object.getOwnPropertyDescriptor(
703 DataView.prototype, "byteOffset").get;
704 var byteLength = Object.getOwnPropertyDescriptor(
705 DataView.prototype, "byteLength").get;
706
707 assertTrue(o.__proto__ === f.prototype);
708 assertTrue(p2 === f.prototype);
709 assertFalse(p === o.__proto__);
710 assertEquals(30, byteOffset.call(o));
711 assertEquals(5, byteLength.call(o));
712 })();
713
714
715 (function() {
716 function f() {}
717
718 var p = f.prototype;
719 var p2 = {};
720 var p3 = {};
721
722 var log = [];
723
724 var pattern = {toString() {
725 log.push("tostring");
726 f.prototype = p3; return "biep" }};
727
728 Object.defineProperty(pattern, Symbol.match, {
729 get() { log.push("match"); f.prototype = p2; return false; }});
730
731 var o = Reflect.construct(RegExp, [pattern], f);
732 assertEquals(["match", "tostring"], log);
733 assertEquals(/biep/, o);
734 assertTrue(o.__proto__ === p2);
735 assertTrue(f.prototype === p3);
736 })();
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/mjsunit/es6/regexp-constructor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698