jscript: Added Math_sin implementation.

This commit is contained in:
Piotr Caban 2009-05-27 01:10:10 +02:00 committed by Alexandre Julliard
parent f57f3aa2f4
commit a67672f9ee
2 changed files with 46 additions and 2 deletions

View File

@ -501,8 +501,22 @@ static HRESULT Math_round(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
static HRESULT Math_sin(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, static HRESULT Math_sin(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{ {
FIXME("\n"); VARIANT v;
return E_NOTIMPL; HRESULT hres;
TRACE("\n");
if(!arg_cnt(dp)) {
if(retv) num_set_nan(retv);
return S_OK;
}
hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
if(FAILED(hres))
return hres;
if(retv) num_set_val(retv, sin(num_val(&v)));
return S_OK;
} }
static HRESULT Math_sqrt(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, static HRESULT Math_sqrt(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,

View File

@ -818,6 +818,36 @@ ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
tmp = Math.log(-Infinity); tmp = Math.log(-Infinity);
ok(isNaN(tmp), "Math.log(-Infinity) is not NaN"); ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
tmp = Math.sin(0);
ok(tmp === 0, "Math.sin(0) = " + tmp);
tmp = Math.sin(Math.PI/2);
ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
tmp = Math.sin(-Math.PI/2);
ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
tmp = Math.sin(Math.PI/3, 2);
ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
tmp = Math.sin(true);
ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
tmp = Math.sin(false);
ok(tmp === 0, "Math.sin(false) = " + tmp);
tmp = Math.sin();
ok(isNaN(tmp), "Math.sin() is not NaN");
tmp = Math.sin(NaN);
ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
tmp = Math.sin(Infinity);
ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
tmp = Math.sin(-Infinity);
ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
var func = function (a) { var func = function (a) {
var a = 1; var a = 1;
if(a) return; if(a) return;