mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 10:41:12 +00:00
jscript: Added implementation of Math_sqrt.
This commit is contained in:
parent
a67672f9ee
commit
8c609c9f50
2 changed files with 46 additions and 2 deletions
|
@ -522,8 +522,22 @@ static HRESULT Math_sin(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d
|
||||||
static HRESULT Math_sqrt(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
static HRESULT Math_sqrt(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, sqrt(num_val(&v)));
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT Math_tan(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
static HRESULT Math_tan(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||||
|
|
|
@ -848,6 +848,36 @@ ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
|
||||||
tmp = Math.sin(-Infinity);
|
tmp = Math.sin(-Infinity);
|
||||||
ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
|
ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
|
||||||
|
|
||||||
|
tmp = Math.sqrt(0);
|
||||||
|
ok(tmp === 0, "Math.sqrt(0) = " + tmp);
|
||||||
|
|
||||||
|
tmp = Math.sqrt(4);
|
||||||
|
ok(tmp === 2, "Math.sqrt(4) = " + tmp);
|
||||||
|
|
||||||
|
tmp = Math.sqrt(-1);
|
||||||
|
ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
|
||||||
|
|
||||||
|
tmp = Math.sqrt(2, 2);
|
||||||
|
ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
|
||||||
|
|
||||||
|
tmp = Math.sqrt(true);
|
||||||
|
ok(tmp === 1, "Math.sqrt(true) = " + tmp);
|
||||||
|
|
||||||
|
tmp = Math.sqrt(false);
|
||||||
|
ok(tmp === 0, "Math.sqrt(false) = " + tmp);
|
||||||
|
|
||||||
|
tmp = Math.sqrt();
|
||||||
|
ok(isNaN(tmp), "Math.sqrt() is not NaN");
|
||||||
|
|
||||||
|
tmp = Math.sqrt(NaN);
|
||||||
|
ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
|
||||||
|
|
||||||
|
tmp = Math.sqrt(Infinity);
|
||||||
|
ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
|
||||||
|
|
||||||
|
tmp = Math.sqrt(-Infinity);
|
||||||
|
ok(isNaN(tmp), "Math.sqrt(-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 a new issue