Jacek Caban : jscript: Added NaN value implementation.

Alexandre Julliard julliard at winehq.org
Thu Oct 16 06:07:08 CDT 2008


Module: wine
Branch: master
Commit: 53ade93cd9dfec1b7a6a7a6db967a5bea224d1d5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=53ade93cd9dfec1b7a6a7a6db967a5bea224d1d5

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Oct 15 18:49:51 2008 -0500

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 a1c76de..e397c3d 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 691ac9e..88bbb8d 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 b989645..5f14eb1 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();




More information about the wine-cvs mailing list