Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
bda96fde
Commit
bda96fde
authored
Mar 21, 2014
by
Jacek Caban
Committed by
Alexandre Julliard
Mar 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vbscript: Added error handling tests.
parent
171ddf5c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
296 additions
and
0 deletions
+296
-0
error.vbs
dlls/vbscript/tests/error.vbs
+250
-0
rsrc.rc
dlls/vbscript/tests/rsrc.rc
+3
-0
run.c
dlls/vbscript/tests/run.c
+43
-0
No files found.
dlls/vbscript/tests/error.vbs
0 → 100644
View file @
bda96fde
'
' Copyright 2014 Jacek Caban for CodeWeavers
'
' This library is free software; you can redistribute it and/or
' modify it under the terms of the GNU Lesser General Public
' License as published by the Free Software Foundation; either
' version 2.1 of the License, or (at your option) any later version.
'
' This library is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
' Lesser General Public License for more details.
'
' You should have received a copy of the GNU Lesser General Public
' License along with this library; if not, write to the Free Software
' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
'
Option
Explicit
const
E_TESTERROR
=
&
h80080008&
const
VB_E_FORLOOPNOTINITIALIZED
=
92
const
VB_E_OBJNOTCOLLECTION
=
451
call
ok
(
Err
.
Number
=
0
,
"Err.Number = "
&
Err
.
Number
)
dim
calledFunc
sub
returnTrue
calledFunc
=
true
returnTrue
=
true
end
sub
sub
testThrow
on
error
resume
next
dim
x
,
y
call
throwInt
(
1000
)
call
ok
(
Err
.
Number
=
0
,
"Err.Number = "
&
Err
.
Number
)
call
throwInt
(
E_TESTERROR
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
call
throwInt
(
1000
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
call
Err
.
clear
()
call
ok
(
Err
.
Number
=
0
,
"Err.Number = "
&
Err
.
Number
)
x
=
6
calledFunc
=
false
x
=
throwInt
(
E_TESTERROR
)
and
returnTrue
()
call
ok
(
x
=
6
,
"x = "
&
x
)
call
ok
(
not
calledFunc
,
"calledFunc = "
&
calledFunc
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
false
call
Err
.
clear
()
if
false
and
throwInt
(
E_TESTERROR
)
then
x
=
true
else
call
ok
(
false
,
"unexpected if else branch on throw"
)
end
if
call
ok
(
x
,
"if branch not taken"
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
false
call
Err
.
clear
()
if
throwInt
(
E_TESTERROR
)
then
x
=
true
call
ok
(
x
,
"if branch not taken"
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
false
call
Err
.
clear
()
if
false
then
call
ok
(
false
,
"unexpected if else branch on throw"
)
elseif
throwInt
(
E_TESTERROR
)
then
x
=
true
else
call
ok
(
false
,
"unexpected if else branch on throw"
)
end
if
call
ok
(
x
,
"elseif branch not taken"
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
call
Err
.
clear
()
if
true
then
call
throwInt
(
E_TESTERROR
)
else
call
ok
(
false
,
"unexpected if else branch on throw"
)
end
if
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
false
call
Err
.
clear
()
do
while
throwInt
(
E_TESTERROR
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
true
exit
do
loop
call
ok
(
x
,
"if branch not taken"
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
0
call
Err
.
clear
()
do
x
=
x
+
1
call
ok
(
Err
.
Number
=
0
,
"Err.Number = "
&
Err
.
Number
)
loop
while
throwInt
(
E_TESTERROR
)
call
ok
(
x
=
1
,
"if branch not taken"
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
0
call
Err
.
clear
()
do
x
=
x
+
1
call
ok
(
Err
.
Number
=
0
,
"Err.Number = "
&
Err
.
Number
)
loop
until
throwInt
(
E_TESTERROR
)
call
ok
(
x
=
1
,
"if branch not taken"
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
call
Err
.
clear
()
x
=
0
while
x
<
2
x
=
x
+
1
call
throwInt
(
E_TESTERROR
)
wend
call
ok
(
x
=
2
,
"x = "
&
x
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
call
Err
.
clear
()
x
=
2
y
=
0
for
each
x
in
throwInt
(
E_TESTERROR
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
y
=
y
+
1
next
call
ok
(
x
=
2
,
"x = "
&
x
)
call
ok
(
y
=
1
,
"y = "
&
y
)
'todo_wine call ok(Err.Number = VB_E_OBJNOTCOLLECTION, "Err.Number = " & Err.Number)
Err
.
clear
()
y
=
0
x
=
6
for
x
=
throwInt
(
E_TESTERROR
)
to
100
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
call
ok
(
x
=
6
,
"x = "
&
x
)
y
=
y
+
1
next
call
ok
(
y
=
1
,
"y = "
&
y
)
call
ok
(
x
=
6
,
"x = "
&
x
)
'todo_wine call ok(Err.Number = VB_E_FORLOOPNOTINITIALIZED, "Err.Number = " & Err.Number)
Err
.
clear
()
y
=
0
x
=
6
for
x
=
100
to
throwInt
(
E_TESTERROR
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
'todo_wine call ok(x = 6, "x = " & x)
y
=
y
+
1
next
call
ok
(
y
=
1
,
"y = "
&
y
)
'todo_wine call ok(x = 6, "x = " & x)
'todo_wine call ok(Err.Number = VB_E_FORLOOPNOTINITIALIZED, "Err.Number = " & Err.Number)
select
case
throwInt
(
E_TESTERROR
)
case
true
call
ok
(
false
,
"unexpected case true"
)
case
false
call
ok
(
false
,
"unexpected case false"
)
case
empty
call
ok
(
false
,
"unexpected case empty"
)
case
else
call
ok
(
false
,
"unexpected case else"
)
end
select
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
x
=
false
select
case
false
case
true
call
ok
(
false
,
"unexpected case true"
)
case
throwInt
(
E_TESTERROR
)
x
=
true
case
else
call
ok
(
false
,
"unexpected case else"
)
end
select
call
ok
(
x
,
"case not executed"
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
'Exception in non-trivial stack context
for
x
=
1
to
1
for
each
y
in
collectionObj
select
case
3
case
1
call
ok
(
false
,
"unexpected case"
)
case
throwInt
(
E_TESTERROR
)
exit
for
case
2
call
ok
(
false
,
"unexpected case"
)
end
select
next
next
end
sub
call
testThrow
dim
x
sub
testOnError
(
resumeNext
)
if
resumeNext
then
on
error
resume
next
else
on
error
goto
0
end
if
x
=
1
throwInt
(
E_TESTERROR
)
x
=
2
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
end
sub
sub
callTestOnError
(
resumeNext
)
on
error
resume
next
call
testOnError
(
resumeNext
)
call
ok
(
Err
.
Number
=
E_TESTERROR
,
"Err.Number = "
&
Err
.
Number
)
end
sub
x
=
0
call
callTestOnError
(
true
)
call
ok
(
x
=
2
,
"x = "
&
x
)
x
=
0
call
callTestOnError
(
false
)
call
ok
(
x
=
1
,
"x = "
&
x
)
sub
testForEachError
()
on
error
resume
next
dim
x
,
y
y
=
false
for
each
x
in
empty
y
=
true
next
call
ok
(
y
,
"for each not executed"
)
'todo_wine call ok(Err.Number = VB_E_OBJNOTCOLLECTION, "Err.Number = " & Err.Number)
end
sub
call
testForEachError
()
call
reportSuccess
()
dlls/vbscript/tests/rsrc.rc
View file @
bda96fde
...
...
@@ -19,6 +19,9 @@
/* @makedep: api.vbs */
api.vbs 40 "api.vbs"
/* @makedep: error.vbs */
error.vbs 40 "error.vbs"
/* @makedep: lang.vbs */
lang.vbs 40 "lang.vbs"
...
...
dlls/vbscript/tests/run.c
View file @
bda96fde
...
...
@@ -113,6 +113,7 @@ DEFINE_EXPECT(EnableModeless);
#define DISPID_GLOBAL_COLLOBJ 1013
#define DISPID_GLOBAL_DOUBLEASSTRING 1014
#define DISPID_GLOBAL_TESTARRAY 1015
#define DISPID_GLOBAL_THROWINT 1016
#define DISPID_TESTOBJ_PROPGET 2000
#define DISPID_TESTOBJ_PROPPUT 2001
...
...
@@ -922,6 +923,11 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
*
pid
=
DISPID_GLOBAL_TESTARRAY
;
return
S_OK
;
}
if
(
!
strcmp_wa
(
bstrName
,
"throwInt"
))
{
test_grfdex
(
grfdex
,
fdexNameCaseInsensitive
);
*
pid
=
DISPID_GLOBAL_THROWINT
;
return
S_OK
;
}
if
(
strict_dispid_check
&&
strcmp_wa
(
bstrName
,
"x"
))
ok
(
0
,
"unexpected call %s %x
\n
"
,
wine_dbgstr_w
(
bstrName
),
grfdex
);
...
...
@@ -1200,6 +1206,39 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
else
test_safearray
(
*
V_ARRAYREF
(
V_VARIANTREF
(
pdp
->
rgvarg
)),
V_I2
(
pdp
->
rgvarg
+
1
));
return
S_OK
;
case
DISPID_GLOBAL_THROWINT
:
{
VARIANT
*
v
=
pdp
->
rgvarg
;
HRESULT
hres
;
ok
((
wFlags
&
~
INVOKE_PROPERTYGET
)
==
INVOKE_FUNC
,
"wFlags = %x
\n
"
,
wFlags
);
ok
(
pdp
!=
NULL
,
"pdp == NULL
\n
"
);
ok
(
pdp
->
rgvarg
!=
NULL
,
"rgvarg == NULL
\n
"
);
ok
(
!
pdp
->
rgdispidNamedArgs
,
"rgdispidNamedArgs != NULL
\n
"
);
ok
(
pdp
->
cArgs
==
1
,
"cArgs = %d
\n
"
,
pdp
->
cArgs
);
ok
(
!
pdp
->
cNamedArgs
,
"cNamedArgs = %d
\n
"
,
pdp
->
cNamedArgs
);
ok
(
pei
!=
NULL
,
"pei == NULL
\n
"
);
if
(
pvarRes
)
{
ok
(
V_VT
(
pvarRes
)
==
VT_EMPTY
,
"V_VT(pvarRes) = %d
\n
"
,
V_VT
(
pvarRes
));
V_VT
(
pvarRes
)
=
VT_BOOL
;
V_BOOL
(
pvarRes
)
=
VARIANT_FALSE
;
}
switch
(
V_VT
(
v
))
{
case
VT_I2
:
hres
=
V_I2
(
v
);
break
;
case
VT_I4
:
hres
=
V_I4
(
v
);
break
;
default:
ok
(
0
,
"unexpected vt %d
\n
"
,
V_VT
(
v
));
return
E_INVALIDARG
;
}
trace
(
"throwing %08x (%d)
\n
"
,
hres
,
hres
);
return
hres
;
}
}
ok
(
0
,
"unexpected call %d
\n
"
,
id
);
...
...
@@ -1941,6 +1980,9 @@ static void run_tests(void)
test_global_vars_ref
(
TRUE
);
test_global_vars_ref
(
FALSE
);
hres
=
parse_script_ar
(
"throwInt(&h80080008&)"
);
ok
(
hres
==
0x80080008
,
"hres = %08x
\n
"
,
hres
);
strict_dispid_check
=
FALSE
;
parse_script_a
(
"Sub testsub
\n
"
...
...
@@ -1960,6 +2002,7 @@ static void run_tests(void)
run_from_res
(
"lang.vbs"
);
run_from_res
(
"api.vbs"
);
run_from_res
(
"regexp.vbs"
);
run_from_res
(
"error.vbs"
);
test_procedures
();
test_gc
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment