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

Unified Diff: test/mjsunit/mjsunit.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 | « test/mjsunit/es6/regexp-constructor.js ('k') | test/mjsunit/regexp.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/mjsunit.js
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js
index f08c29339ab788cc912ef185f651c028261f48e8..27f4d3942ad035fe9f743702381c7e6cff783737 100644
--- a/test/mjsunit/mjsunit.js
+++ b/test/mjsunit/mjsunit.js
@@ -113,14 +113,39 @@ var assertUnoptimized;
(function () { // Scope for utility functions.
+ var ObjectPrototypeToString = Object.prototype.toString;
+ var NumberPrototypeValueOf = Number.prototype.valueOf;
+ var BooleanPrototypeValueOf = Boolean.prototype.valueOf;
+ var StringPrototypeValueOf = String.prototype.valueOf;
+ var DatePrototypeValueOf = Date.prototype.valueOf;
+ var RegExpPrototypeToString = RegExp.prototype.toString;
+ var ArrayPrototypeMap = Array.prototype.map;
+ var ArrayPrototypeJoin = Array.prototype.join;
+
function classOf(object) {
// Argument must not be null or undefined.
- var string = Object.prototype.toString.call(object);
+ var string = ObjectPrototypeToString.call(object);
// String has format [object <ClassName>].
return string.substring(8, string.length - 1);
}
+ function ValueOf(value) {
+ switch (classOf(value)) {
+ case "Number":
+ return NumberPrototypeValueOf.call(value);
+ case "String":
+ return StringPrototypeValueOf.call(value);
+ case "Boolean":
+ return BooleanPrototypeValueOf.call(value);
+ case "Date":
+ return DatePrototypeValueOf.call(value);
+ default:
+ return value;
+ }
+ }
+
+
function PrettyPrint(value) {
switch (typeof value) {
case "string":
@@ -137,19 +162,21 @@ var assertUnoptimized;
if (value === null) return "null";
var objectClass = classOf(value);
switch (objectClass) {
- case "Number":
- case "String":
- case "Boolean":
- case "Date":
- return objectClass + "(" + PrettyPrint(value.valueOf()) + ")";
- case "RegExp":
- return value.toString();
- case "Array":
- return "[" + value.map(PrettyPrintArrayElement).join(",") + "]";
- case "Object":
- break;
- default:
- return objectClass + "()";
+ case "Number":
+ case "String":
+ case "Boolean":
+ case "Date":
+ return objectClass + "(" + PrettyPrint(ValueOf(value)) + ")";
+ case "RegExp":
+ return RegExpPrototypeToString.call(value);
+ case "Array":
+ var mapped = ArrayPrototypeMap.call(value, PrettyPrintArrayElement);
+ var joined = ArrayPrototypeJoin.call(mapped, ",");
+ return "[" + joined + "]";
+ case "Object":
+ break;
+ default:
+ return objectClass + "()";
}
// [[Class]] is "Object".
var name = value.constructor.name;
@@ -211,7 +238,8 @@ var assertUnoptimized;
if (objectClass !== classOf(b)) return false;
if (objectClass === "RegExp") {
// For RegExp, just compare pattern and flags using its toString.
- return (a.toString() === b.toString());
+ return RegExpPrototypeToString.call(a) ===
+ RegExpPrototypeToString.call(b);
}
// Functions are only identical to themselves.
if (objectClass === "Function") return false;
@@ -227,7 +255,7 @@ var assertUnoptimized;
}
if (objectClass === "String" || objectClass === "Number" ||
objectClass === "Boolean" || objectClass === "Date") {
- if (a.valueOf() !== b.valueOf()) return false;
+ if (ValueOf(a) !== ValueOf(b)) return false;
}
return deepObjectEquals(a, b);
}
« no previous file with comments | « test/mjsunit/es6/regexp-constructor.js ('k') | test/mjsunit/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698