jscript: Better handling of to_integer result in String.charAt.

This commit is contained in:
Jacek Caban 2012-05-03 10:40:13 +02:00 committed by Alexandre Julliard
parent 3ee7438a5f
commit 0143201eac
2 changed files with 5 additions and 7 deletions

View File

@ -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) {

View File

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