summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-10 00:11:02 +0000
committerLinus Groh <mail@linusgroh.de>2022-12-10 11:23:23 +0000
commitf1d8a645105c4f6acba61f56d0cd6aee7bc68e32 (patch)
tree87c88598508e0e2f6ea82096c4ccb6ea1658e3c0 /Userland/Libraries/LibJS/Runtime
parentabf1ba89cdfeb05cb5bba0dde31007235cc82b96 (diff)
downloadserenity-f1d8a645105c4f6acba61f56d0cd6aee7bc68e32.zip
LibJS: Add spec comments to is_strictly_equal()
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index 062e2ad59e..e66135e3e7 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -2181,20 +2181,33 @@ bool same_value_non_numeric(Value lhs, Value rhs)
// 7.2.15 IsStrictlyEqual ( x, y ), https://tc39.es/ecma262/#sec-isstrictlyequal
bool is_strictly_equal(Value lhs, Value rhs)
{
+ // 1. If Type(x) is different from Type(y), return false.
if (!same_type_for_equality(lhs, rhs))
return false;
+ // 2. If x is a Number, then
if (lhs.is_number()) {
+ // a. Return Number::equal(x, y).
+
+ // 6.1.6.1.13 Number::equal ( x, y ), https://tc39.es/ecma262/#sec-numeric-types-number-equal
+ // 1. If x is NaN, return false.
+ // 2. If y is NaN, return false.
if (lhs.is_nan() || rhs.is_nan())
return false;
+ // 3. If x is the same Number value as y, return true.
+ // 4. If x is +0𝔽 and y is -0𝔽, return true.
+ // 5. If x is -0𝔽 and y is +0𝔽, return true.
if (lhs.as_double() == rhs.as_double())
return true;
+ // 6. Return false.
return false;
}
+ // FIXME: This should be handled in SameValueNonNumber now (formerly SameValueNonNumeric)
if (lhs.is_bigint())
return lhs.as_bigint().big_integer() == rhs.as_bigint().big_integer();
+ // 3. Return SameValueNonNumber(x, y).
return same_value_non_numeric(lhs, rhs);
}