jscript: Added Math.pow implementation.

This commit is contained in:
Jacek Caban 2008-09-21 15:46:22 +02:00 committed by Alexandre Julliard
parent 37b69e9a9e
commit c4fe1b2efd
2 changed files with 31 additions and 2 deletions

View File

@ -272,11 +272,31 @@ static HRESULT Math_min(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d
return S_OK;
}
/* ECMA-262 3rd Edition 15.8.2.13 */
static HRESULT Math_pow(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
VARIANT x, y;
HRESULT hres;
TRACE("\n");
if(arg_cnt(dp) < 2) {
FIXME("unimplemented arg_cnt %d\n", arg_cnt(dp));
return E_NOTIMPL;
}
hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &x);
if(FAILED(hres))
return hres;
hres = to_number(dispex->ctx, get_arg(dp, 1), ei, &y);
if(FAILED(hres))
return hres;
if(retv)
num_set_val(retv, pow(num_val(&x), num_val(&y)));
return S_OK;
}
static HRESULT Math_random(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,

View File

@ -291,4 +291,13 @@ ok(tmp === 1, "Math.abs(true) = " + tmp);
tmp = Math.abs(-3, 2);
ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
tmp = Math.pow(2, 2);
ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
tmp = Math.pow(4, 0.5);
ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
tmp = Math.pow(2, 2, 3);
ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
reportSuccess();