mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
jscript: Correctly handle NaN in to_integer.
This commit is contained in:
parent
efda5561d0
commit
ec769d2d95
@ -449,10 +449,14 @@ HRESULT to_integer(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret)
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
if(V_VT(&num) == VT_I4)
|
||||
if(V_VT(&num) == VT_I4) {
|
||||
*ret = num;
|
||||
else
|
||||
}else if(isnan(V_R8(&num))) {
|
||||
V_VT(ret) = VT_I4;
|
||||
V_I4(ret) = 0;
|
||||
}else {
|
||||
num_set_val(ret, V_R8(&num) >= 0.0 ? floor(V_R8(&num)) : -floor(-V_R8(&num)));
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -231,6 +231,8 @@ tmp = "abc".charAt(-1);
|
||||
ok(tmp === "", "'abc',charAt(-1) = " + tmp);
|
||||
tmp = "abc".charAt(0,2);
|
||||
ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
|
||||
tmp = "abc".charAt(NaN);
|
||||
ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
|
||||
|
||||
tmp = "abc".charCodeAt(0);
|
||||
ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
|
||||
|
Loading…
Reference in New Issue
Block a user