jscript: Added to_string(VT_I4) implementation.
This commit is contained in:
parent
788197d592
commit
c137281469
|
@ -253,19 +253,54 @@ HRESULT to_int32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, INT *ret)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static BSTR int_to_bstr(INT i)
|
||||
{
|
||||
WCHAR buf[12], *p;
|
||||
BOOL neg = FALSE;
|
||||
|
||||
if(!i) {
|
||||
static const WCHAR zeroW[] = {'0',0};
|
||||
return SysAllocString(zeroW);
|
||||
}
|
||||
|
||||
if(i < 0) {
|
||||
neg = TRUE;
|
||||
i = -i;
|
||||
}
|
||||
|
||||
p = buf + sizeof(buf)/sizeof(*buf)-1;
|
||||
*p-- = 0;
|
||||
while(i) {
|
||||
*p-- = i%10 + '0';
|
||||
i /= 10;
|
||||
}
|
||||
|
||||
if(neg)
|
||||
*p = '-';
|
||||
else
|
||||
p++;
|
||||
|
||||
return SysAllocString(p);
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 9.8 */
|
||||
HRESULT to_string(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, BSTR *str)
|
||||
{
|
||||
switch(V_VT(v)) {
|
||||
case VT_I4:
|
||||
*str = int_to_bstr(V_I4(v));
|
||||
break;
|
||||
|
||||
case VT_BSTR:
|
||||
*str = SysAllocString(V_BSTR(v));
|
||||
return S_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("unsupported vt %d\n", V_VT(v));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
return E_NOTIMPL;
|
||||
return *str ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 9.9 */
|
||||
|
|
|
@ -312,6 +312,10 @@ ok(+true === 1, "+true !== 1");
|
|||
ok(+false === 0, "+false !== 0");
|
||||
ok(+null === 0, "+null !== 0");
|
||||
|
||||
ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
|
||||
ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
|
||||
ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
|
||||
|
||||
ok(1 < 3.4, "1 < 3.4 failed");
|
||||
ok(!(3.4 < 1), "3.4 < 1");
|
||||
ok("abc" < "abcd", "abc < abcd failed");
|
||||
|
@ -544,5 +548,6 @@ ok(tmp.length === 7, "tmp.length !== 7");
|
|||
ok(tmp["0"] === undefined, "tmp[0] is not undefined");
|
||||
ok(tmp["3"] === 2, "tmp[3] !== 2");
|
||||
ok(tmp["6"] === true, "tmp[6] !== true");
|
||||
ok(tmp[2] === 1, "tmp[2] !== 1");
|
||||
|
||||
reportSuccess();
|
||||
|
|
Loading…
Reference in New Issue