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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/classes-subclass-builtins.js
diff --git a/test/mjsunit/es6/classes-subclass-builtins.js b/test/mjsunit/es6/classes-subclass-builtins.js
index 74dd489cb88dbf547226e4fe915736bc9b991153..ccf386153e639d3b747409061ad64c899d8689a6 100644
--- a/test/mjsunit/es6/classes-subclass-builtins.js
+++ b/test/mjsunit/es6/classes-subclass-builtins.js
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --allow-natives-syntax
+// Flags: --allow-natives-syntax --harmony-reflect --harmony-regexp-subclass
"use strict";
@@ -604,3 +604,133 @@ function TestMapSetSubclassing(container, is_map) {
class A extends Symbol {}
assertThrows("new A");
})();
+
+
+(function() {
+ function f() {}
+
+ var p = f.prototype;
+ var p2 = {};
+ var o = Reflect.construct(
+ Number, [{valueOf() { f.prototype=p2; return 10; }}], f);
+
+ assertTrue(o.__proto__ === f.prototype);
+ assertTrue(p2 === f.prototype);
+ assertFalse(p === o.__proto__);
+ assertEquals(10, Number.prototype.valueOf.call(o));
+})();
+
+
+(function() {
+ function f() {}
+
+ var p = f.prototype;
+ var p2 = {};
+ var o = Reflect.construct(
+ String, [{toString() { f.prototype=p2; return "biep"; }}], f);
+
+ assertTrue(o.__proto__ === f.prototype);
+ assertTrue(p2 === o.__proto__);
+ assertFalse(p === o.__proto__);
+ assertEquals("biep", String.prototype.toString.call(o));
+})();
+
+
+(function() {
+ function f() {}
+
+ var p = f.prototype;
+ var p2 = {};
+ var o = Reflect.construct(
+ Date, [{valueOf() { f.prototype=p2; return 1447836899614; }}], f);
+
+ assertTrue(o.__proto__ === f.prototype);
+ assertTrue(p2 === f.prototype);
+ assertFalse(p === o.__proto__);
+ assertEquals(new Date(1447836899614).toString(),
+ Date.prototype.toString.call(o));
+})();
+
+
+(function() {
+ function f() {}
+
+ var p = f.prototype;
+ var p2 = {};
+ var o = Reflect.construct(
+ Date, [2015, {valueOf() { f.prototype=p2; return 10; }}], f);
+
+ assertTrue(o.__proto__ === f.prototype);
+ assertTrue(p2 === f.prototype);
+ assertFalse(p === o.__proto__);
+ assertEquals(new Date(2015, 10).getYear(), Date.prototype.getYear.call(o));
+ assertEquals(new Date(2015, 10).getMonth(), Date.prototype.getMonth.call(o));
+})();
+
+
+(function() {
+ function f() {}
+
+ var p = f.prototype;
+ var p2 = {};
+ var o = Reflect.construct(
+ DataView, [new ArrayBuffer(100),
+ {valueOf(){ f.prototype=p2; return 5; }}], f);
+
+ var byteOffset = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteOffset").get;
+ var byteLength = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteLength").get;
+
+ assertTrue(o.__proto__ === f.prototype);
+ assertTrue(p2 === f.prototype);
+ assertFalse(p === o.__proto__);
+ assertEquals(5, byteOffset.call(o));
+ assertEquals(95, byteLength.call(o));
+})();
+
+
+(function() {
+ function f() {}
+
+ var p = f.prototype;
+ var p2 = {};
+ var o = Reflect.construct(
+ DataView, [new ArrayBuffer(100),
+ 30, {valueOf() { f.prototype=p2; return 5; }}], f);
+
+ var byteOffset = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteOffset").get;
+ var byteLength = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteLength").get;
+
+ assertTrue(o.__proto__ === f.prototype);
+ assertTrue(p2 === f.prototype);
+ assertFalse(p === o.__proto__);
+ assertEquals(30, byteOffset.call(o));
+ assertEquals(5, byteLength.call(o));
+})();
+
+
+(function() {
+ function f() {}
+
+ var p = f.prototype;
+ var p2 = {};
+ var p3 = {};
+
+ var log = [];
+
+ var pattern = {toString() {
+ log.push("tostring");
+ f.prototype = p3; return "biep" }};
+
+ Object.defineProperty(pattern, Symbol.match, {
+ get() { log.push("match"); f.prototype = p2; return false; }});
+
+ var o = Reflect.construct(RegExp, [pattern], f);
+ assertEquals(["match", "tostring"], log);
+ assertEquals(/biep/, o);
+ assertTrue(o.__proto__ === p2);
+ assertTrue(f.prototype === p3);
+})();
« 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