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)) {
|
||||
VARIANT num;
|
||||
double d;
|
||||
|
||||
hres = to_integer(ctx, get_arg(dp, 0), ei, &num);
|
||||
if(FAILED(hres)) {
|
||||
SysFreeString(val_str);
|
||||
return hres;
|
||||
}
|
||||
|
||||
if(V_VT(&num) == VT_I4) {
|
||||
pos = V_I4(&num);
|
||||
}else {
|
||||
WARN("pos = %lf\n", V_R8(&num));
|
||||
pos = -1;
|
||||
}
|
||||
d = num_val(&num);
|
||||
pos = is_int32(d) ? d : -1;
|
||||
}
|
||||
|
||||
if(!retv) {
|
||||
|
|
|
@ -308,6 +308,8 @@ tmp = "abc".charAt(0,2);
|
|||
ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
|
||||
tmp = "abc".charAt(NaN);
|
||||
ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
|
||||
tmp = "abc".charAt(bigInt);
|
||||
ok(tmp === "", "'abc',charAt(bigInt) = " + tmp);
|
||||
|
||||
tmp = "abc".charCodeAt(0);
|
||||
ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
|
||||
|
|
Loading…
Reference in New Issue