diff options
author | Linus Groh <mail@linusgroh.de> | 2020-04-01 21:00:09 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-01 22:09:37 +0200 |
commit | a0da97cb5a18f038266b1babf127c00befe11a88 (patch) | |
tree | f489e95b39531c063cfd5ec8219071e628655561 /Libraries | |
parent | 2577712a1c680f0dae93b9de6e81a7999c608469 (diff) | |
download | serenity-a0da97cb5a18f038266b1babf127c00befe11a88.zip |
LibJS: Add NaN to global object
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibJS/Runtime/GlobalObject.cpp | 1 | ||||
-rw-r--r-- | Libraries/LibJS/Tests/NaN-basic.js | 4 |
2 files changed, 5 insertions, 0 deletions
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<ConsoleObject>()); put("Date", heap().allocate<DateConstructor>()); put("Error", heap().allocate<ErrorConstructor>()); 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); |