vbscript: Return correct error for null start in InStr and more tests.
Signed-off-by: Dmitry Kislyuk <dimaki@rocketmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7a71f98640
commit
120b220979
|
@ -1662,6 +1662,9 @@ static HRESULT Global_InStr(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
|
|||
}
|
||||
|
||||
if(startv) {
|
||||
if(V_VT(startv) == VT_NULL)
|
||||
return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
|
||||
|
||||
hres = to_int(startv, &start);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
|
|
@ -435,6 +435,34 @@ Call ok(x = 3, "InStr returned " & x)
|
|||
x = InStr(1, "23456", 34, 1)
|
||||
Call ok(x = 2, "InStr returned " & x)
|
||||
|
||||
x = InStr(2, "", "abcd", 0)
|
||||
Call ok(x = 0, "InStr returned " & x)
|
||||
|
||||
x = InStr(4, "abcdef", "", 0)
|
||||
Call ok(x = 4, "InStr returned " & x)
|
||||
|
||||
x = InStr(20, "abcdef", "", 0)
|
||||
Call ok(x = 0, "InStr returned " & x)
|
||||
|
||||
x = InStr(4, "", "", 0)
|
||||
Call ok(x = 0, "InStr returned " & x)
|
||||
|
||||
Sub testInStrError(arg1, arg2, arg3, arg4, error_num)
|
||||
on error resume next
|
||||
Dim x
|
||||
|
||||
Call Err.clear()
|
||||
x = InStr(arg1, arg2, arg3, arg4)
|
||||
Call ok(Err.number = error_num, "Err.number = " & Err.number)
|
||||
End Sub
|
||||
|
||||
call testInStrError(2, "abcd", null, 0, 0)
|
||||
call testInStrError(2, Null, "abcd", 0, 0)
|
||||
call testInStrError(Null, "abcd", "abcd", 0, 94)
|
||||
call testInStrError(2, "abcd", "abcd", null, 94)
|
||||
call testInStrError(-20, "abcd", "abcd", 1, 5)
|
||||
Call testInStrError(2, "abcd", "abcd", 10, 5)
|
||||
|
||||
|
||||
x = InStrRev("bcabcd", "bc")
|
||||
Call ok(x = 4, "InStrRev returned " & x)
|
||||
|
|
Loading…
Reference in New Issue