diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c index 0dac085abcc..53ff314f602 100644 --- a/dlls/jscript/date.c +++ b/dlls/jscript/date.c @@ -81,11 +81,8 @@ static const WCHAR setUTCFullYearW[] = {'s','e','t','U','T','C','F','u','l','l', /* ECMA-262 3rd Edition 15.9.1.14 */ static inline DOUBLE time_clip(DOUBLE time) { - /* FIXME: Handle inf */ - if(8.64e15 < time || time < -8.64e15) { - FIXME("return NaN\n"); - return 0.0; + return ret_nan(); } return floor(time); diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index 01d9eb245a2..a714f8ef4e4 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -351,8 +351,8 @@ static HRESULT JSGlobal_parseInt(DispatchEx *dispex, LCID lcid, WORD flags, DISP HRESULT hres; if(!arg_cnt(dp)) { - FIXME("NAN\n"); - return E_NOTIMPL; + if(retv) num_set_nan(retv); + return S_OK; } if(arg_cnt(dp) >= 2) { diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 4862b28f55f..6cf3535c92f 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -255,6 +255,13 @@ static inline void num_set_nan(VARIANT *v) #endif } +static inline DOUBLE ret_nan() +{ + VARIANT v; + num_set_nan(&v); + return V_R8(&v); +} + static inline void num_set_inf(VARIANT *v, BOOL positive) { V_VT(v) = VT_R8; diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index eeceb1f6932..82c1043490e 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -254,8 +254,8 @@ static HRESULT String_charCodeAt(DispatchEx *dispex, LCID lcid, WORD flags, DISP return hres; if(V_VT(&v) != VT_I4 || V_I4(&v) < 0 || V_I4(&v) >= length) { - FIXME("NAN\n"); - return E_FAIL; + if(retv) num_set_nan(&v); + return S_OK; } idx = V_I4(&v); diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index a17b0670877..2b6e0b28852 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -934,6 +934,12 @@ var date = new Date(); date = new Date(100); ok(date.getTime() === 100, "date.getTime() = " + date.getTime()); ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime()); +date = new Date(8.64e15); +ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime()); +date = new Date(8.64e15+1); +ok(isNaN(0+date.getTime()), "date.getTime() is not NaN"); +date = new Date(Infinity); +ok(isNaN(0+date.getTime()), "date.getTime() is not NaN"); ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI)); ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);