From 53ade93cd9dfec1b7a6a7a6db967a5bea224d1d5 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 15 Oct 2008 18:49:51 -0500 Subject: [PATCH] jscript: Added NaN value implementation. --- dlls/jscript/global.c | 15 +++++++++++++-- dlls/jscript/jscript.h | 10 ++++++++++ dlls/jscript/tests/lang.js | 3 +++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index a1c76dee656..e397c3de585 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -108,8 +108,19 @@ static HRESULT constructor_call(DispatchEx *constr, LCID lcid, WORD flags, DISPP static HRESULT JSGlobal_NaN(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("\n"); + + switch(flags) { + case DISPATCH_PROPERTYGET: + num_set_nan(retv); + break; + + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; } static HRESULT JSGlobal_Infinity(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 691ac9ef902..88bbb8dc809 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -242,6 +242,16 @@ static inline void num_set_val(VARIANT *v, DOUBLE d) } } +static inline void num_set_nan(VARIANT *v) +{ + V_VT(v) = VT_R8; +#ifdef NAN + V_R8(v) = NAN; +#else + V_UI8(v) = (ULONGLONG)0x7ff80000<<32; +#endif +} + const char *debugstr_variant(const VARIANT*); HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**); diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index b989645fb68..5f14eb15c91 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -785,7 +785,10 @@ if (true) else ok(true, "else should be associated with nearest if statement"); +ok(isNaN(NaN) === true, "isNaN(NaN) !== true"); ok(isNaN(0.5) === false, "isNaN(0.5) !== false"); ok(isNaN() === true, "isNaN() !== true"); +ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true"); +ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false"); reportSuccess();