jscript: Added object to number conversion implementation.

This commit is contained in:
Jacek Caban 2008-09-25 00:52:10 +02:00 committed by Alexandre Julliard
parent 5b3630ec7b
commit 136f7933c6
2 changed files with 17 additions and 0 deletions

View File

@ -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;

View File

@ -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\"");