jscript: Added Math_sin implementation.
This commit is contained in:
parent
f57f3aa2f4
commit
a67672f9ee
|
@ -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,
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue