Commit f96aa1f3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Properly support overloaded values in to_int32.

parent c06d362b
......@@ -659,11 +659,18 @@ HRESULT to_int32(script_ctx_t *ctx, jsval_t v, INT *ret)
double n;
HRESULT hres;
const double p32 = (double)0xffffffff + 1;
hres = to_number(ctx, v, &n);
if(FAILED(hres))
return hres;
*ret = is_finite(n) ? n : 0;
if(is_finite(n))
n = n > 0 ? fmod(n, p32) : -fmod(-n, p32);
else
n = 0;
*ret = (UINT32)n;
return S_OK;
}
......
......@@ -632,6 +632,12 @@ tmp = 10;
ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
tmp = (123 * Math.pow(2,32) + 2) | 0;
ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
tmp = (-123 * Math.pow(2,32) + 2) | 0;
ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
tmp = 3 & 5;
ok(tmp === 1, "3 & 5 !== 1");
ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment