jscript: Added object to number conversion implementation.
This commit is contained in:
parent
5b3630ec7b
commit
136f7933c6
|
@ -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\"");
|
||||
|
|
Loading…
Reference in New Issue