[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/712034 Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#48486}
This commit is contained in:
parent
a80e5c5b62
commit
126b2bd281
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user