From a0da97cb5a18f038266b1babf127c00befe11a88 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 1 Apr 2020 21:00:09 +0100 Subject: LibJS: Add NaN to global object --- Libraries/LibJS/Runtime/GlobalObject.cpp | 1 + Libraries/LibJS/Tests/NaN-basic.js | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'Libraries') diff --git a/Libraries/LibJS/Runtime/GlobalObject.cpp b/Libraries/LibJS/Runtime/GlobalObject.cpp index 4c3b4daa55..c09c5ce3cd 100644 --- a/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -18,6 +18,7 @@ GlobalObject::GlobalObject() put_native_function("gc", gc); put_native_function("isNaN", is_nan); + put("NaN", js_nan()); put("console", heap().allocate()); put("Date", heap().allocate()); put("Error", heap().allocate()); diff --git a/Libraries/LibJS/Tests/NaN-basic.js b/Libraries/LibJS/Tests/NaN-basic.js index 75ae62f16e..a129564b42 100644 --- a/Libraries/LibJS/Tests/NaN-basic.js +++ b/Libraries/LibJS/Tests/NaN-basic.js @@ -3,7 +3,11 @@ function assert(x) { if (!x) throw 1; } try { var nan = undefined + 1; assert(nan + "" == "NaN"); + assert(NaN + "" == "NaN"); + assert(nan !== nan); + assert(NaN !== NaN); assert(isNaN(nan) === true); + assert(isNaN(NaN) === true); assert(isNaN(0) === false); assert(isNaN(undefined) === true); assert(isNaN(null) === false); -- cgit v1.2.3