1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 05:57:41 +00:00

LibJS: Add NaN to global object

This commit is contained in:
Linus Groh 2020-04-01 21:00:09 +01:00 committed by Andreas Kling
parent 2577712a1c
commit a0da97cb5a
2 changed files with 5 additions and 0 deletions

View file

@ -18,6 +18,7 @@ GlobalObject::GlobalObject()
put_native_function("gc", gc); put_native_function("gc", gc);
put_native_function("isNaN", is_nan); put_native_function("isNaN", is_nan);
put("NaN", js_nan());
put("console", heap().allocate<ConsoleObject>()); put("console", heap().allocate<ConsoleObject>());
put("Date", heap().allocate<DateConstructor>()); put("Date", heap().allocate<DateConstructor>());
put("Error", heap().allocate<ErrorConstructor>()); put("Error", heap().allocate<ErrorConstructor>());

View file

@ -3,7 +3,11 @@ function assert(x) { if (!x) throw 1; }
try { try {
var nan = undefined + 1; var nan = undefined + 1;
assert(nan + "" == "NaN"); assert(nan + "" == "NaN");
assert(NaN + "" == "NaN");
assert(nan !== nan);
assert(NaN !== NaN);
assert(isNaN(nan) === true); assert(isNaN(nan) === true);
assert(isNaN(NaN) === true);
assert(isNaN(0) === false); assert(isNaN(0) === false);
assert(isNaN(undefined) === true); assert(isNaN(undefined) === true);
assert(isNaN(null) === false); assert(isNaN(null) === false);