Commit 13802c8b authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[bigint] Adapt test/mjsunit/mjsunit.js.

R=jkummerow@chromium.org

Bug: v8:6791
Change-Id: I9eb5b9aeeb060d660ec41b7a3287089edd833197
Reviewed-on: https://chromium-review.googlesource.com/737796Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48992}
parent 3942370c
...@@ -192,6 +192,12 @@ var failWithMessage; ...@@ -192,6 +192,12 @@ var failWithMessage;
var ArrayPrototypeMap = Array.prototype.map; var ArrayPrototypeMap = Array.prototype.map;
var ArrayPrototypePush = Array.prototype.push; var ArrayPrototypePush = Array.prototype.push;
var BigIntPrototypeValueOf;
// TODO(neis): Remove try-catch once BigInts are enabled by default.
try {
BigIntPrototypeValueOf = BigInt.prototype.valueOf;
} catch(e) {}
function classOf(object) { function classOf(object) {
// Argument must not be null or undefined. // Argument must not be null or undefined.
var string = ObjectPrototypeToString.call(object); var string = ObjectPrototypeToString.call(object);
...@@ -204,6 +210,8 @@ var failWithMessage; ...@@ -204,6 +210,8 @@ var failWithMessage;
switch (classOf(value)) { switch (classOf(value)) {
case "Number": case "Number":
return NumberPrototypeValueOf.call(value); return NumberPrototypeValueOf.call(value);
case "BigInt":
return BigIntPrototypeValueOf.call(value);
case "String": case "String":
return StringPrototypeValueOf.call(value); return StringPrototypeValueOf.call(value);
case "Boolean": case "Boolean":
...@@ -223,6 +231,8 @@ var failWithMessage; ...@@ -223,6 +231,8 @@ var failWithMessage;
case "number": case "number":
if (value === 0 && (1 / value) < 0) return "-0"; if (value === 0 && (1 / value) < 0) return "-0";
// FALLTHROUGH. // FALLTHROUGH.
case "bigint":
return String(value) + "n";
case "boolean": case "boolean":
case "undefined": case "undefined":
case "function": case "function":
...@@ -233,6 +243,7 @@ var failWithMessage; ...@@ -233,6 +243,7 @@ var failWithMessage;
var objectClass = classOf(value); var objectClass = classOf(value);
switch (objectClass) { switch (objectClass) {
case "Number": case "Number":
case "BigInt":
case "String": case "String":
case "Boolean": case "Boolean":
case "Date": case "Date":
...@@ -346,7 +357,8 @@ var failWithMessage; ...@@ -346,7 +357,8 @@ var failWithMessage;
return true; return true;
} }
if (objectClass === "String" || objectClass === "Number" || if (objectClass === "String" || objectClass === "Number" ||
objectClass === "Boolean" || objectClass === "Date") { objectClass === "BigInt" || objectClass === "Boolean" ||
objectClass === "Date") {
if (ValueOf(a) !== ValueOf(b)) return false; if (ValueOf(a) !== ValueOf(b)) return false;
} }
return deepObjectEquals(a, b); return deepObjectEquals(a, b);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment