jscript: Better handling of to_integer result in String.charAt.
This commit is contained in:
parent
3ee7438a5f
commit
0143201eac
@ -303,19 +303,15 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
|
|||||||
|
|
||||||
if(arg_cnt(dp)) {
|
if(arg_cnt(dp)) {
|
||||||
VARIANT num;
|
VARIANT num;
|
||||||
|
double d;
|
||||||
|
|
||||||
hres = to_integer(ctx, get_arg(dp, 0), ei, &num);
|
hres = to_integer(ctx, get_arg(dp, 0), ei, &num);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
SysFreeString(val_str);
|
SysFreeString(val_str);
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
d = num_val(&num);
|
||||||
if(V_VT(&num) == VT_I4) {
|
pos = is_int32(d) ? d : -1;
|
||||||
pos = V_I4(&num);
|
|
||||||
}else {
|
|
||||||
WARN("pos = %lf\n", V_R8(&num));
|
|
||||||
pos = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!retv) {
|
if(!retv) {
|
||||||
|
@ -308,6 +308,8 @@ tmp = "abc".charAt(0,2);
|
|||||||
ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
|
ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
|
||||||
tmp = "abc".charAt(NaN);
|
tmp = "abc".charAt(NaN);
|
||||||
ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
|
ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
|
||||||
|
tmp = "abc".charAt(bigInt);
|
||||||
|
ok(tmp === "", "'abc',charAt(bigInt) = " + tmp);
|
||||||
|
|
||||||
tmp = "abc".charCodeAt(0);
|
tmp = "abc".charCodeAt(0);
|
||||||
ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
|
ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user