mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 12:47:41 +00:00
LibJS: Add global isNaN() function
This commit is contained in:
parent
9a78b4af2c
commit
04ced9e24a
2 changed files with 9 additions and 0 deletions
|
@ -18,6 +18,11 @@ GlobalObject::GlobalObject()
|
||||||
this_object->heap().collect_garbage();
|
this_object->heap().collect_garbage();
|
||||||
return js_undefined();
|
return js_undefined();
|
||||||
});
|
});
|
||||||
|
put_native_function("isNaN", [](Object*, Vector<Value> arguments) -> Value {
|
||||||
|
if (arguments.size() < 1)
|
||||||
|
return js_undefined();
|
||||||
|
return Value(arguments[0].is_nan());
|
||||||
|
});
|
||||||
put("Math", heap().allocate<MathObject>());
|
put("Math", heap().allocate<MathObject>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@ function assert(x) { if (!x) throw 1; }
|
||||||
try {
|
try {
|
||||||
var nan = undefined + 1;
|
var nan = undefined + 1;
|
||||||
assert(nan + "" == "NaN");
|
assert(nan + "" == "NaN");
|
||||||
|
assert(isNaN(nan) === true);
|
||||||
|
assert(isNaN(0) === false);
|
||||||
|
assert(isNaN(undefined) === false);
|
||||||
|
assert(isNaN(null) === false);
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("FAIL: " + e);
|
console.log("FAIL: " + e);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue