Commit 126b2bd2 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[bigint] Adapt Object::SameValueZero.

Also add tests for Object::SameValue.

R=jkummerow@chromium.org

Bug: v8:6791
Change-Id: I0611044dcfee4c6ba836629cf82d1589135e4ab0
Reviewed-on: https://chromium-review.googlesource.com/712034Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48486}
parent a80e5c5b
......@@ -2409,8 +2409,6 @@ Smi* Object::GetOrCreateHash(Isolate* isolate) {
bool Object::SameValue(Object* other) {
if (other == this) return true;
// The object is either a number, a name, an odd-ball,
// a real JS object, or a Harmony proxy.
if (IsNumber() && other->IsNumber()) {
double this_value = Number();
double other_value = other->Number();
......@@ -2434,8 +2432,6 @@ bool Object::SameValue(Object* other) {
bool Object::SameValueZero(Object* other) {
if (other == this) return true;
// The object is either a number, a name, an odd-ball,
// a real JS object, or a Harmony proxy.
if (IsNumber() && other->IsNumber()) {
double this_value = Number();
double other_value = other->Number();
......@@ -2446,6 +2442,9 @@ bool Object::SameValueZero(Object* other) {
if (IsString() && other->IsString()) {
return String::cast(this)->Equals(String::cast(other));
}
if (IsBigInt() && other->IsBigInt()) {
return BigInt::Equal(BigInt::cast(this), BigInt::cast(other));
}
return false;
}
......
......@@ -286,6 +286,18 @@ const six = BigInt(6);
assertTrue(Reflect.defineProperty(obj, 'foo', {value: zero}));
assertTrue(Reflect.defineProperty(obj, 'foo', {value: another_zero}));
assertFalse(Reflect.defineProperty(obj, 'foo', {value: one}));
}{
assertTrue(%SameValue(zero, zero));
assertTrue(%SameValue(zero, another_zero));
assertFalse(%SameValue(zero, +0));
assertFalse(%SameValue(zero, -0));
assertFalse(%SameValue(+0, zero));
assertFalse(%SameValue(-0, zero));
assertTrue(%SameValue(one, one));
assertTrue(%SameValue(one, another_one));
}
// SameValueZero
......@@ -328,6 +340,18 @@ const six = BigInt(6);
assertTrue(new Map([[one, 42]]).has(one));
assertTrue(new Map([[one, 42]]).has(another_one));
}{
assertTrue(%SameValueZero(zero, zero));
assertTrue(%SameValueZero(zero, another_zero));
assertFalse(%SameValueZero(zero, +0));
assertFalse(%SameValueZero(zero, -0));
assertFalse(%SameValueZero(+0, zero));
assertFalse(%SameValueZero(-0, zero));
assertTrue(%SameValueZero(one, one));
assertTrue(%SameValueZero(one, another_one));
}
// ToNumber
......
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