jscript: Bettter handling of to_number result in String.indexOf.

This commit is contained in:
Jacek Caban 2012-05-03 10:40:45 +02:00 committed by Alexandre Julliard
parent 621180e81c
commit baa07477d2
2 changed files with 6 additions and 6 deletions

View File

@ -494,15 +494,13 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(arg_cnt(dp) >= 2) {
VARIANT ival;
double d;
hres = to_integer(ctx, get_arg(dp,1), ei, &ival);
if(SUCCEEDED(hres)) {
if(V_VT(&ival) == VT_I4)
pos = V_VT(&ival) > 0 ? V_I4(&ival) : 0;
else
pos = V_R8(&ival) > 0.0 ? length : 0;
if(pos > length)
pos = length;
d = num_val(&ival);
if(d > 0.0)
pos = is_int32(d) ? min((int)d, length) : length;
}
}

View File

@ -475,6 +475,8 @@ tmp = "abcd".indexOf("bc",0,"test");
ok(tmp === 1, "indexOf = " + tmp);
tmp = "abcd".indexOf();
ok(tmp == -1, "indexOf = " + tmp);
tmp = "abcd".indexOf("b", bigInt);
ok(tmp == -1, "indexOf = " + tmp);
tmp = "abcd".lastIndexOf("bc",1);
ok(tmp === 1, "lastIndexOf = " + tmp);