Commit 136f7933 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added object to number conversion implementation.

parent 5b3630ec
......@@ -335,6 +335,18 @@ HRESULT to_number(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret)
break;
case VT_BSTR:
return str_to_number(V_BSTR(v), ret);
case VT_DISPATCH: {
VARIANT prim;
HRESULT hres;
hres = to_primitive(ctx, v, ei, &prim);
if(FAILED(hres))
return hres;
hres = to_number(ctx, &prim, ei, ret);
VariantClear(&prim);
return hres;
}
case VT_BOOL:
V_VT(ret) = VT_I4;
V_I4(ret) = V_BOOL(v) ? 1 : 0;
......
......@@ -359,6 +359,11 @@ ok(+"-3" === -3, "+'-3' !== -3");
ok(+"0xff" === 255, "+'0xff' !== 255");
ok(+"3e3" === 3000, "+'3e3' !== 3000");
tmp = new Number(1);
ok(+tmp === 1, "ToNumber(new Number(1)) = " + (+tmp));
tmp = new String("1");
ok(+tmp === 1, "ToNumber(new String('1')) = " + (+tmp));
ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
......
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