Jacek Caban : jscript: Added isNaN implementation.
Alexandre Julliard
julliard at winehq.org
Wed Oct 15 10:08:25 CDT 2008
Module: wine
Branch: master
Commit: 88c12282e35a24cfcb0bb137efde4275363e0155
URL: http://source.winehq.org/git/wine.git/?a=commit;h=88c12282e35a24cfcb0bb137efde4275363e0155
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Oct 14 16:07:01 2008 -0500
jscript: Added isNaN implementation.
---
dlls/jscript/global.c | 29 +++++++++++++++++++++++++++--
dlls/jscript/tests/lang.js | 3 +++
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 432bf00..a1c76de 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -16,6 +16,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
+
+#include <math.h>
+
#include "jscript.h"
#include "engine.h"
@@ -252,8 +257,28 @@ static HRESULT JSGlobal_eval(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
static HRESULT JSGlobal_isNaN(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ VARIANT_BOOL ret = VARIANT_FALSE;
+ VARIANT num;
+ HRESULT hres;
+
+ TRACE("\n");
+
+ if(arg_cnt(dp)) {
+ hres = to_number(dispex->ctx, get_arg(dp,0), ei, &num);
+ if(FAILED(hres))
+ return hres;
+
+ if(V_VT(&num) == VT_R8 && isnan(V_R8(&num)))
+ ret = VARIANT_TRUE;
+ }else {
+ ret = VARIANT_TRUE;
+ }
+
+ if(retv) {
+ V_VT(retv) = VT_BOOL;
+ V_BOOL(retv) = ret;
+ }
+ return S_OK;
}
static HRESULT JSGlobal_isFinite(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 720c166..16dadbd 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -773,4 +773,7 @@ try {
ok(false, "deleteTest not throwed exception?");
}catch(ex) {}
+ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
+ok(isNaN() === true, "isNaN() !== true");
+
reportSuccess();
More information about the wine-cvs
mailing list