1c2c66affSColin Finck /*
2c2c66affSColin Finck  * Copyright 2011 Jacek Caban for CodeWeavers
3c2c66affSColin Finck  *
4c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
5c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
6c2c66affSColin Finck  * License as published by the Free Software Foundation; either
7c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
8c2c66affSColin Finck  *
9c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
10c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12c2c66affSColin Finck  * Lesser General Public License for more details.
13c2c66affSColin Finck  *
14c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
15c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
16c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17c2c66affSColin Finck  */
18c2c66affSColin Finck 
19c2c66affSColin Finck #include <stdio.h>
20c2c66affSColin Finck 
21c2c66affSColin Finck #define COBJMACROS
22c2c66affSColin Finck #define CONST_VTABLE
23c2c66affSColin Finck 
24c2c66affSColin Finck #include <ole2.h>
25c2c66affSColin Finck #include <dispex.h>
26c2c66affSColin Finck #include <activscp.h>
27c2c66affSColin Finck 
28ff857de1SAmine Khaldi #include "vbsregexp55.h"
29c2c66affSColin Finck 
30ff857de1SAmine Khaldi #include "wine/test.h"
31c2c66affSColin Finck 
32c2c66affSColin Finck #ifdef _WIN64
33c2c66affSColin Finck 
34c2c66affSColin Finck #define IActiveScriptParse_QueryInterface IActiveScriptParse64_QueryInterface
35c2c66affSColin Finck #define IActiveScriptParse_Release IActiveScriptParse64_Release
36c2c66affSColin Finck #define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
37c2c66affSColin Finck #define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
38c2c66affSColin Finck #define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_64_Release
39c2c66affSColin Finck #define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_64_ParseProcedureText
40c2c66affSColin Finck 
41c2c66affSColin Finck #else
42c2c66affSColin Finck 
43c2c66affSColin Finck #define IActiveScriptParse_QueryInterface IActiveScriptParse32_QueryInterface
44c2c66affSColin Finck #define IActiveScriptParse_Release IActiveScriptParse32_Release
45c2c66affSColin Finck #define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
46c2c66affSColin Finck #define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
47c2c66affSColin Finck #define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_32_Release
48c2c66affSColin Finck #define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_32_ParseProcedureText
49c2c66affSColin Finck 
50c2c66affSColin Finck #endif
51c2c66affSColin Finck 
52c2c66affSColin Finck extern const CLSID CLSID_VBScript;
53c2c66affSColin Finck extern const CLSID CLSID_VBScriptRegExp;
54c2c66affSColin Finck 
55c2c66affSColin Finck #define DEFINE_EXPECT(func) \
56c2c66affSColin Finck     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
57c2c66affSColin Finck 
58c2c66affSColin Finck #define SET_EXPECT(func) \
59c2c66affSColin Finck     expect_ ## func = TRUE
60c2c66affSColin Finck 
61*7d76303dSAmine Khaldi #define REF_EXPECT(func) \
62*7d76303dSAmine Khaldi     (&expect_ ## func), (&called_ ## func)
63*7d76303dSAmine Khaldi 
64c2c66affSColin Finck #define CHECK_EXPECT2(func) \
65c2c66affSColin Finck     do { \
66c2c66affSColin Finck         ok(expect_ ##func, "unexpected call " #func "\n"); \
67c2c66affSColin Finck         called_ ## func = TRUE; \
68c2c66affSColin Finck     }while(0)
69c2c66affSColin Finck 
70c2c66affSColin Finck #define CHECK_EXPECT(func) \
71c2c66affSColin Finck     do { \
72c2c66affSColin Finck         CHECK_EXPECT2(func); \
73c2c66affSColin Finck         expect_ ## func = FALSE; \
74c2c66affSColin Finck     }while(0)
75c2c66affSColin Finck 
76c2c66affSColin Finck #define CHECK_CALLED(func) \
77c2c66affSColin Finck     do { \
78c2c66affSColin Finck         ok(called_ ## func, "expected " #func "\n"); \
79c2c66affSColin Finck         expect_ ## func = called_ ## func = FALSE; \
80c2c66affSColin Finck     }while(0)
81c2c66affSColin Finck 
82*7d76303dSAmine Khaldi #define CHECK_NOT_CALLED(func) \
83*7d76303dSAmine Khaldi     do { \
84*7d76303dSAmine Khaldi         ok(!called_ ## func, "unexpected " #func "\n"); \
85*7d76303dSAmine Khaldi         expect_ ## func = called_ ## func = FALSE; \
86*7d76303dSAmine Khaldi     }while(0)
87*7d76303dSAmine Khaldi 
88c2c66affSColin Finck #define CLEAR_CALLED(func) \
89c2c66affSColin Finck     expect_ ## func = called_ ## func = FALSE
90c2c66affSColin Finck 
91c2c66affSColin Finck DEFINE_EXPECT(global_success_d);
92c2c66affSColin Finck DEFINE_EXPECT(global_success_i);
93c2c66affSColin Finck DEFINE_EXPECT(global_vbvar_d);
94c2c66affSColin Finck DEFINE_EXPECT(global_vbvar_i);
95c2c66affSColin Finck DEFINE_EXPECT(global_letobj_i);
96c2c66affSColin Finck DEFINE_EXPECT(global_setobj_i);
97*7d76303dSAmine Khaldi DEFINE_EXPECT(global_globalcallback_i);
98c2c66affSColin Finck DEFINE_EXPECT(testobj_propget_d);
99c2c66affSColin Finck DEFINE_EXPECT(testobj_propget_i);
100c2c66affSColin Finck DEFINE_EXPECT(testobj_propput_d);
101c2c66affSColin Finck DEFINE_EXPECT(testobj_propput_i);
102c2c66affSColin Finck DEFINE_EXPECT(testobj_value_i);
103c2c66affSColin Finck DEFINE_EXPECT(global_propargput_d);
104c2c66affSColin Finck DEFINE_EXPECT(global_propargput_i);
105c2c66affSColin Finck DEFINE_EXPECT(global_propargput1_d);
106c2c66affSColin Finck DEFINE_EXPECT(global_propargput1_i);
107c2c66affSColin Finck DEFINE_EXPECT(global_testoptionalarg_i);
108*7d76303dSAmine Khaldi DEFINE_EXPECT(global_testerrorobject_i);
109c2c66affSColin Finck DEFINE_EXPECT(collectionobj_newenum_i);
110c2c66affSColin Finck DEFINE_EXPECT(Next);
111c2c66affSColin Finck DEFINE_EXPECT(GetWindow);
112c2c66affSColin Finck DEFINE_EXPECT(GetUIBehavior);
113c2c66affSColin Finck DEFINE_EXPECT(EnableModeless);
114c2c66affSColin Finck DEFINE_EXPECT(OnScriptError);
115*7d76303dSAmine Khaldi DEFINE_EXPECT(OnEnterScript);
116*7d76303dSAmine Khaldi DEFINE_EXPECT(OnLeaveScript);
117c2c66affSColin Finck 
118c2c66affSColin Finck #define DISPID_GLOBAL_REPORTSUCCESS 1000
119c2c66affSColin Finck #define DISPID_GLOBAL_TRACE         1001
120c2c66affSColin Finck #define DISPID_GLOBAL_OK            1002
121c2c66affSColin Finck #define DISPID_GLOBAL_GETVT         1003
122c2c66affSColin Finck #define DISPID_GLOBAL_ISENGLANG     1004
123c2c66affSColin Finck #define DISPID_GLOBAL_VBVAR         1005
124c2c66affSColin Finck #define DISPID_GLOBAL_TESTOBJ       1006
125c2c66affSColin Finck #define DISPID_GLOBAL_ISNULLDISP    1007
126c2c66affSColin Finck #define DISPID_GLOBAL_TESTDISP      1008
127c2c66affSColin Finck #define DISPID_GLOBAL_REFOBJ        1009
128c2c66affSColin Finck #define DISPID_GLOBAL_COUNTER       1010
129c2c66affSColin Finck #define DISPID_GLOBAL_PROPARGPUT    1011
130c2c66affSColin Finck #define DISPID_GLOBAL_PROPARGPUT1   1012
131c2c66affSColin Finck #define DISPID_GLOBAL_COLLOBJ       1013
132c2c66affSColin Finck #define DISPID_GLOBAL_DOUBLEASSTRING 1014
133c2c66affSColin Finck #define DISPID_GLOBAL_TESTARRAY     1015
134c2c66affSColin Finck #define DISPID_GLOBAL_THROWINT      1016
135c2c66affSColin Finck #define DISPID_GLOBAL_TESTOPTIONALARG 1017
136c2c66affSColin Finck #define DISPID_GLOBAL_LETOBJ        1018
137c2c66affSColin Finck #define DISPID_GLOBAL_SETOBJ        1019
138942c4265SAmine Khaldi #define DISPID_GLOBAL_TODO_WINE_OK  1020
139942c4265SAmine Khaldi #define DISPID_GLOBAL_WEEKSTARTDAY  1021
140*7d76303dSAmine Khaldi #define DISPID_GLOBAL_GLOBALCALLBACK  1022
141*7d76303dSAmine Khaldi #define DISPID_GLOBAL_TESTERROROBJECT 1023
142c2c66affSColin Finck 
143c2c66affSColin Finck #define DISPID_TESTOBJ_PROPGET      2000
144c2c66affSColin Finck #define DISPID_TESTOBJ_PROPPUT      2001
145*7d76303dSAmine Khaldi #define DISPID_TESTOBJ_KEYWORD      2002
146c2c66affSColin Finck 
147c2c66affSColin Finck #define DISPID_COLLOBJ_RESET        3000
148c2c66affSColin Finck 
149c2c66affSColin Finck #define FACILITY_VBS 0xa
150c2c66affSColin Finck #define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code)
151c2c66affSColin Finck 
152c2c66affSColin Finck static const WCHAR testW[] = {'t','e','s','t',0};
153c2c66affSColin Finck static const WCHAR emptyW[] = {0};
154c2c66affSColin Finck 
155c2c66affSColin Finck static BOOL strict_dispid_check, is_english, allow_ui;
156942c4265SAmine Khaldi static int first_day_of_week;
157c2c66affSColin Finck static const char *test_name = "(null)";
158c2c66affSColin Finck static int test_counter;
159c2c66affSColin Finck static SCRIPTUICHANDLING uic_handling = SCRIPTUICHANDLING_NOUIERROR;
160c2c66affSColin Finck static IDispatchEx testObj;
161c2c66affSColin Finck static HRESULT onerror_hres = E_NOTIMPL;
162*7d76303dSAmine Khaldi static BOOL strict_enter_script;
163c2c66affSColin Finck 
a2bstr(const char * str)164c2c66affSColin Finck static BSTR a2bstr(const char *str)
165c2c66affSColin Finck {
166c2c66affSColin Finck     BSTR ret;
167c2c66affSColin Finck     int len;
168c2c66affSColin Finck 
169c2c66affSColin Finck     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
170c2c66affSColin Finck     ret = SysAllocStringLen(NULL, len-1);
171c2c66affSColin Finck     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
172c2c66affSColin Finck 
173c2c66affSColin Finck     return ret;
174c2c66affSColin Finck }
175c2c66affSColin Finck 
strcmp_wa(LPCWSTR strw,const char * stra)176c2c66affSColin Finck static int strcmp_wa(LPCWSTR strw, const char *stra)
177c2c66affSColin Finck {
178c2c66affSColin Finck     CHAR buf[512];
179c2c66affSColin Finck     WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
180c2c66affSColin Finck     return lstrcmpA(buf, stra);
181c2c66affSColin Finck }
182c2c66affSColin Finck 
stricmp_wa(LPCWSTR strw,const char * stra)183*7d76303dSAmine Khaldi static int stricmp_wa(LPCWSTR strw, const char *stra)
184*7d76303dSAmine Khaldi {
185*7d76303dSAmine Khaldi     CHAR buf[512];
186*7d76303dSAmine Khaldi     WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
187*7d76303dSAmine Khaldi     return lstrcmpiA(buf, stra);
188*7d76303dSAmine Khaldi }
189*7d76303dSAmine Khaldi 
vt2a(VARIANT * v)190c2c66affSColin Finck static const char *vt2a(VARIANT *v)
191c2c66affSColin Finck {
192c2c66affSColin Finck     if(V_VT(v) == (VT_BYREF|VT_VARIANT)) {
193c2c66affSColin Finck         static char buf[64];
194c2c66affSColin Finck         sprintf(buf, "%s*", vt2a(V_BYREF(v)));
195c2c66affSColin Finck         return buf;
196c2c66affSColin Finck     }
197c2c66affSColin Finck 
198c2c66affSColin Finck     switch(V_VT(v)) {
199c2c66affSColin Finck     case VT_EMPTY:
200c2c66affSColin Finck         return "VT_EMPTY";
201c2c66affSColin Finck     case VT_NULL:
202c2c66affSColin Finck         return "VT_NULL";
203c2c66affSColin Finck     case VT_I2:
204c2c66affSColin Finck         return "VT_I2";
205c2c66affSColin Finck     case VT_I4:
206c2c66affSColin Finck         return "VT_I4";
207c2c66affSColin Finck     case VT_R4:
208c2c66affSColin Finck         return "VT_R4";
209c2c66affSColin Finck     case VT_R8:
210c2c66affSColin Finck         return "VT_R8";
211c2c66affSColin Finck     case VT_CY:
212c2c66affSColin Finck         return "VT_CY";
213c2c66affSColin Finck     case VT_DATE:
214c2c66affSColin Finck         return "VT_DATE";
215c2c66affSColin Finck     case VT_BSTR:
216c2c66affSColin Finck         return "VT_BSTR";
217c2c66affSColin Finck     case VT_DISPATCH:
218c2c66affSColin Finck         return "VT_DISPATCH";
219c2c66affSColin Finck     case VT_BOOL:
220c2c66affSColin Finck         return "VT_BOOL";
221c2c66affSColin Finck     case VT_ARRAY|VT_VARIANT:
222c2c66affSColin Finck         return "VT_ARRAY|VT_VARIANT";
223c2c66affSColin Finck     case VT_ARRAY|VT_BYREF|VT_VARIANT:
224c2c66affSColin Finck         return "VT_ARRAY|VT_BYREF|VT_VARIANT";
225c2c66affSColin Finck     case VT_UI1:
226c2c66affSColin Finck         return "VT_UI1";
227c2c66affSColin Finck     default:
228c2c66affSColin Finck         ok(0, "unknown vt %d\n", V_VT(v));
229c2c66affSColin Finck         return NULL;
230c2c66affSColin Finck     }
231c2c66affSColin Finck }
232c2c66affSColin Finck 
233942c4265SAmine Khaldi /* Sets is_english to true if the user interface is in English. Note that this
234942c4265SAmine Khaldi  * does not presume the formatting of dates, numbers, etc.
235942c4265SAmine Khaldi  * Sets first_day_of_week to 1 if Sunday, 2 if Monday, and so on.
236c2c66affSColin Finck  */
detect_locale(void)237942c4265SAmine Khaldi static void detect_locale(void)
238c2c66affSColin Finck {
239942c4265SAmine Khaldi     HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
240942c4265SAmine Khaldi     LANGID (WINAPI *pGetThreadUILanguage)(void) = (void*)GetProcAddress(kernel32, "GetThreadUILanguage");
241c2c66affSColin Finck 
242942c4265SAmine Khaldi     is_english = ((!pGetThreadUILanguage || PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH) &&
243942c4265SAmine Khaldi                   PRIMARYLANGID(GetUserDefaultUILanguage()) == LANG_ENGLISH &&
244942c4265SAmine Khaldi                   PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH);
245c2c66affSColin Finck 
246942c4265SAmine Khaldi     GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
247942c4265SAmine Khaldi                    (void*)&first_day_of_week, sizeof(first_day_of_week));
248942c4265SAmine Khaldi     first_day_of_week = 1 + (first_day_of_week + 1) % 7;
249c2c66affSColin Finck }
250c2c66affSColin Finck 
ServiceProvider_QueryInterface(IServiceProvider * iface,REFIID riid,void ** ppv)251c2c66affSColin Finck static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
252c2c66affSColin Finck {
253c2c66affSColin Finck     ok(0, "unexpected call\n");
254c2c66affSColin Finck     return E_NOINTERFACE;
255c2c66affSColin Finck }
256c2c66affSColin Finck 
ServiceProvider_AddRef(IServiceProvider * iface)257c2c66affSColin Finck static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
258c2c66affSColin Finck {
259c2c66affSColin Finck     return 2;
260c2c66affSColin Finck }
261c2c66affSColin Finck 
ServiceProvider_Release(IServiceProvider * iface)262c2c66affSColin Finck static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
263c2c66affSColin Finck {
264c2c66affSColin Finck     return 1;
265c2c66affSColin Finck }
266c2c66affSColin Finck 
ServiceProvider_QueryService(IServiceProvider * iface,REFGUID guidService,REFIID riid,void ** ppv)267c2c66affSColin Finck static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
268c2c66affSColin Finck         REFIID riid, void **ppv)
269c2c66affSColin Finck {
270c2c66affSColin Finck     ok(0, "unexpected service %s\n", wine_dbgstr_guid(guidService));
271c2c66affSColin Finck     return E_NOINTERFACE;
272c2c66affSColin Finck }
273c2c66affSColin Finck 
274c2c66affSColin Finck static const IServiceProviderVtbl ServiceProviderVtbl = {
275c2c66affSColin Finck     ServiceProvider_QueryInterface,
276c2c66affSColin Finck     ServiceProvider_AddRef,
277c2c66affSColin Finck     ServiceProvider_Release,
278c2c66affSColin Finck     ServiceProvider_QueryService
279c2c66affSColin Finck };
280c2c66affSColin Finck 
281c2c66affSColin Finck static IServiceProvider caller_sp = { &ServiceProviderVtbl };
282c2c66affSColin Finck 
test_disp(IDispatch * disp)283c2c66affSColin Finck static void test_disp(IDispatch *disp)
284c2c66affSColin Finck {
285c2c66affSColin Finck     DISPID id, public_prop_id, public_prop2_id, public_func_id, public_sub_id, defvalget_id, gs_getter_id;
286c2c66affSColin Finck     DISPID named_args[5] = {DISPID_PROPERTYPUT};
287c2c66affSColin Finck     VARIANT v, args[5];
288c2c66affSColin Finck     DISPPARAMS dp = {args, named_args};
289c2c66affSColin Finck     IDispatchEx *dispex;
290c2c66affSColin Finck     EXCEPINFO ei = {0};
291c2c66affSColin Finck     BSTR str;
292c2c66affSColin Finck     HRESULT hres;
293c2c66affSColin Finck 
294c2c66affSColin Finck     hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
295c2c66affSColin Finck     ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
296c2c66affSColin Finck 
297c2c66affSColin Finck     str = a2bstr("publicProp");
298c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &public_prop_id);
299c2c66affSColin Finck     SysFreeString(str);
300c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicProp) failed: %08x\n", hres);
301c2c66affSColin Finck 
302c2c66affSColin Finck     str = a2bstr("PUBLICPROP");
303c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, 0, &id);
304c2c66affSColin Finck     SysFreeString(str);
305c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(PUBLICPROP) failed: %08x\n", hres);
306c2c66affSColin Finck     ok(public_prop_id == id, "id = %d\n", public_prop_id);
307c2c66affSColin Finck 
308c2c66affSColin Finck     str = a2bstr("publicPROP2");
309c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &public_prop2_id);
310c2c66affSColin Finck     SysFreeString(str);
311c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicProp2) failed: %08x\n", hres);
312c2c66affSColin Finck 
313c2c66affSColin Finck     str = a2bstr("defValGet");
314c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &defvalget_id);
315c2c66affSColin Finck     SysFreeString(str);
316c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(defValGet) failed: %08x\n", hres);
317c2c66affSColin Finck     ok(defvalget_id == DISPID_VALUE, "id = %d\n", defvalget_id);
318c2c66affSColin Finck 
319c2c66affSColin Finck     str = a2bstr("privateProp");
320c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id);
321c2c66affSColin Finck     SysFreeString(str);
322c2c66affSColin Finck     ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(privateProp) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
323c2c66affSColin Finck     ok(id == -1, "id = %d\n", id);
324c2c66affSColin Finck 
325c2c66affSColin Finck     str = a2bstr("class_initialize");
326c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id);
327c2c66affSColin Finck     SysFreeString(str);
328c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicProp2) failed: %08x\n", hres);
329c2c66affSColin Finck 
330c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
331c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
332c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
333c2c66affSColin Finck 
334c2c66affSColin Finck     V_VT(args) = VT_BOOL;
335c2c66affSColin Finck     V_BOOL(args) = VARIANT_TRUE;
336c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 1;
337c2c66affSColin Finck     V_VT(&v) = VT_BOOL;
338c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYPUT, &dp, &v, &ei, NULL);
339c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
340c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
341c2c66affSColin Finck 
342c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
343c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
344c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
345c2c66affSColin Finck     ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
346c2c66affSColin Finck     ok(V_BOOL(&v), "V_BOOL(v) = %x\n", V_BOOL(&v));
347c2c66affSColin Finck 
348c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
349c2c66affSColin Finck     hres = IDispatchEx_Invoke(dispex, public_prop_id, &IID_NULL, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
350c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
351c2c66affSColin Finck     ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
352c2c66affSColin Finck     ok(V_BOOL(&v), "V_BOOL(v) = %x\n", V_BOOL(&v));
353c2c66affSColin Finck 
354c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
355c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
356c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
357c2c66affSColin Finck     ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
358c2c66affSColin Finck     ok(V_BOOL(&v), "V_BOOL(v) = %x\n", V_BOOL(&v));
359c2c66affSColin Finck 
360c2c66affSColin Finck     dp.cArgs = 1;
361c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
362c2c66affSColin Finck     ok(hres == DISP_E_MEMBERNOTFOUND, "InvokeEx failed: %08x, expected DISP_E_MEMBERNOTFOUND\n", hres);
363c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
364c2c66affSColin Finck 
365c2c66affSColin Finck     SET_EXPECT(testobj_value_i);
366c2c66affSColin Finck     V_VT(args) = VT_DISPATCH;
367c2c66affSColin Finck     V_DISPATCH(args) = (IDispatch*)&testObj;
368c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 1;
369c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
370c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
371c2c66affSColin Finck     CHECK_CALLED(testobj_value_i);
372c2c66affSColin Finck 
373c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
374c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
375c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
376c2c66affSColin Finck     ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
377c2c66affSColin Finck     ok(V_I2(&v) == 0, "V_I2(v) = %d\n", V_I2(&v));
378c2c66affSColin Finck 
379c2c66affSColin Finck     V_VT(args) = VT_DISPATCH;
380c2c66affSColin Finck     V_DISPATCH(args) = (IDispatch*)&testObj;
381c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 1;
382c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, &dp, NULL, &ei, NULL);
383c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
384c2c66affSColin Finck 
385c2c66affSColin Finck     V_VT(args) = VT_DISPATCH;
386c2c66affSColin Finck     V_DISPATCH(args) = (IDispatch*)&testObj;
387c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 1;
388c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYPUTREF, &dp, NULL, &ei, NULL);
389c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
390c2c66affSColin Finck 
391c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
392c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
393c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
394c2c66affSColin Finck     ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
395c2c66affSColin Finck     ok(V_DISPATCH(&v) == (IDispatch*)&testObj, "V_DISPATCH(v) != testObj\n");
396c2c66affSColin Finck 
397c2c66affSColin Finck     V_VT(args) = VT_BOOL;
398c2c66affSColin Finck     V_BOOL(args) = VARIANT_TRUE;
399c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 1;
400c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, &dp, NULL, &ei, NULL);
401c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
402c2c66affSColin Finck 
403c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
404c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
405c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
406c2c66affSColin Finck     ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
407c2c66affSColin Finck     ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
408c2c66affSColin Finck 
409c2c66affSColin Finck     V_VT(args) = VT_BOOL;
410c2c66affSColin Finck     V_BOOL(args) = VARIANT_FALSE;
411c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 1;
412c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYPUTREF, &dp, NULL, &ei, NULL);
413c2c66affSColin Finck     ok(hres == DISP_E_EXCEPTION, "InvokeEx failed: %08x, expected DISP_E_EXCEPTION\n", hres);
414c2c66affSColin Finck 
415c2c66affSColin Finck     V_VT(args) = VT_BOOL;
416c2c66affSColin Finck     V_BOOL(args) = VARIANT_FALSE;
417c2c66affSColin Finck     dp.cArgs = 1;
418c2c66affSColin Finck     dp.cNamedArgs = 0;
419c2c66affSColin Finck     V_VT(&v) = VT_BOOL;
420c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
421c2c66affSColin Finck     ok(hres == DISP_E_PARAMNOTOPTIONAL, "InvokeEx failed: %08x, expected DISP_E_PARAMNOTOPTIONAL\n", hres);
422c2c66affSColin Finck 
423c2c66affSColin Finck     str = a2bstr("publicFunction");
424c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &public_func_id);
425c2c66affSColin Finck     SysFreeString(str);
426c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicFunction) failed: %08x\n", hres);
427c2c66affSColin Finck     ok(public_func_id != -1, "public_func_id = -1\n");
428c2c66affSColin Finck 
429c2c66affSColin Finck     str = a2bstr("publicSub");
430c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &public_sub_id);
431c2c66affSColin Finck     SysFreeString(str);
432c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicSub) failed: %08x\n", hres);
433c2c66affSColin Finck     ok(public_sub_id != -1, "public_func_id = -1\n");
434c2c66affSColin Finck 
435c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
436c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
437c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
438c2c66affSColin Finck     ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
439c2c66affSColin Finck     ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v));
440c2c66affSColin Finck 
441c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
442c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
443c2c66affSColin Finck     ok(hres == DISP_E_MEMBERNOTFOUND, "InvokeEx failed: %08x, expected DISP_E_MEMBERNOTFOUND\n", hres);
444c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
445c2c66affSColin Finck 
446c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
447c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
448c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
449c2c66affSColin Finck     ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
450c2c66affSColin Finck     ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v));
451c2c66affSColin Finck 
452c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
453c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
454c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
455c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
456c2c66affSColin Finck 
457c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
458c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
459c2c66affSColin Finck     ok(hres == DISP_E_MEMBERNOTFOUND, "InvokeEx failed: %08x, expected DISP_E_MEMBERNOTFOUND\n", hres);
460c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
461c2c66affSColin Finck 
462c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
463c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
464c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
465c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
466c2c66affSColin Finck 
467c2c66affSColin Finck     V_VT(args) = VT_BOOL;
468c2c66affSColin Finck     V_BOOL(args) = VARIANT_TRUE;
469c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 1;
470c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
471c2c66affSColin Finck     ok(FAILED(hres), "InvokeEx succeeded: %08x\n", hres);
472c2c66affSColin Finck 
473c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
474c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
475c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
476c2c66affSColin Finck     ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
477c2c66affSColin Finck     ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v));
478c2c66affSColin Finck 
479c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
480c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
481c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
482c2c66affSColin Finck     ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
483c2c66affSColin Finck     ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v));
484c2c66affSColin Finck 
485c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
486c2c66affSColin Finck     hres = IDispatchEx_Invoke(dispex, public_func_id, &IID_NULL, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
487c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
488c2c66affSColin Finck     ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
489c2c66affSColin Finck     ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v));
490c2c66affSColin Finck 
491c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
492c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
493c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
494c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
495c2c66affSColin Finck 
496c2c66affSColin Finck     dp.cArgs = dp.cNamedArgs = 0;
497c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
498c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
499c2c66affSColin Finck     ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
500c2c66affSColin Finck 
501c2c66affSColin Finck     str = a2bstr("privateSub");
502c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id);
503c2c66affSColin Finck     SysFreeString(str);
504c2c66affSColin Finck     ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(privateSub) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
505c2c66affSColin Finck     ok(id == -1, "id = %d\n", id);
506c2c66affSColin Finck 
507c2c66affSColin Finck     str = a2bstr("dynprop");
508c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive|fdexNameEnsure, &id);
509c2c66affSColin Finck     ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(privateProp) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
510c2c66affSColin Finck     ok(id == -1, "id = %d\n", id);
511c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameEnsure, &id);
512c2c66affSColin Finck     ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(privateProp) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
513c2c66affSColin Finck     ok(id == -1, "id = %d\n", id);
514c2c66affSColin Finck     SysFreeString(str);
515c2c66affSColin Finck 
516c2c66affSColin Finck     str = a2bstr("publicProp");
517c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, 0x80000000|fdexNameCaseInsensitive, &public_prop_id);
518c2c66affSColin Finck     SysFreeString(str);
519c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicProp) failed: %08x\n", hres);
520c2c66affSColin Finck 
521c2c66affSColin Finck     id = 0xdeadbeef;
522c2c66affSColin Finck     str = a2bstr("publicProp");
523c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
524c2c66affSColin Finck     SysFreeString(str);
525c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicProp) failed: %08x\n", hres);
526c2c66affSColin Finck     ok(id == public_prop_id, "id = %d, expected %d\n", id, public_prop_id);
527c2c66affSColin Finck 
528c2c66affSColin Finck     id = 0xdeadbeef;
529c2c66affSColin Finck     str = a2bstr("publicprop");
530c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
531c2c66affSColin Finck     SysFreeString(str);
532c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicProp) failed: %08x\n", hres);
533c2c66affSColin Finck     ok(id == public_prop_id, "id = %d, expected %d\n", id, public_prop_id);
534c2c66affSColin Finck 
535c2c66affSColin Finck     str = a2bstr("gsGetProp");
536c2c66affSColin Finck     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &gs_getter_id);
537c2c66affSColin Finck     SysFreeString(str);
538c2c66affSColin Finck     ok(hres == S_OK, "GetDispID(publicFunction) failed: %08x\n", hres);
539c2c66affSColin Finck     ok(gs_getter_id != -1, "gs_getter_id = -1\n");
540c2c66affSColin Finck 
541c2c66affSColin Finck     V_VT(args) = VT_BOOL;
542c2c66affSColin Finck     V_BOOL(args) = VARIANT_TRUE;
543c2c66affSColin Finck     dp.cNamedArgs = 0;
544c2c66affSColin Finck     dp.cArgs = 1;
545c2c66affSColin Finck     V_VT(&v) = VT_I8;
546c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, gs_getter_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
547c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
548c2c66affSColin Finck     ok(V_VT(&v) == VT_BOOL && V_BOOL(&v), "V_VT(v) = %d\n", V_VT(&v));
549c2c66affSColin Finck 
550c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, gs_getter_id, 0, DISPATCH_PROPERTYGET, &dp, NULL, &ei, NULL);
551c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
552c2c66affSColin Finck 
553c2c66affSColin Finck     V_VT(args) = VT_BOOL;
554c2c66affSColin Finck     V_BOOL(args) = VARIANT_FALSE;
555c2c66affSColin Finck     dp.cArgs = 1;
556c2c66affSColin Finck     V_VT(&v) = VT_I8;
557c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, gs_getter_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
558c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
559c2c66affSColin Finck     ok(V_VT(&v) == VT_BOOL && !V_BOOL(&v), "V_VT(v) = %d\n", V_VT(&v));
560c2c66affSColin Finck 
561c2c66affSColin Finck     V_VT(args) = VT_BOOL;
562c2c66affSColin Finck     V_BOOL(args) = VARIANT_TRUE;
563c2c66affSColin Finck     V_VT(&v) = VT_I8;
564c2c66affSColin Finck     dp.cArgs = 1;
565c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(dispex, gs_getter_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
566c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
567c2c66affSColin Finck     ok(V_VT(&v) == VT_BOOL && V_BOOL(&v), "V_VT(v) = %d\n", V_VT(&v));
568c2c66affSColin Finck 
569c2c66affSColin Finck     IDispatchEx_Release(dispex);
570c2c66affSColin Finck }
571c2c66affSColin Finck 
test_safearray(SAFEARRAY * safearray,unsigned indims)572c2c66affSColin Finck static void test_safearray(SAFEARRAY *safearray, unsigned indims)
573c2c66affSColin Finck {
574c2c66affSColin Finck     int i, exdims = indims;
575c2c66affSColin Finck 
576c2c66affSColin Finck     if(!exdims)
577c2c66affSColin Finck         exdims = 1;
578c2c66affSColin Finck     ok(safearray->cDims == exdims, "safearray->cDims = %d, expected %d\n", safearray->cDims, exdims);
579c2c66affSColin Finck     todo_wine
580c2c66affSColin Finck     ok(safearray->fFeatures == (FADF_VARIANT|FADF_HAVEVARTYPE|FADF_FIXEDSIZE|FADF_STATIC),
581c2c66affSColin Finck        "safearray->fFeatures = %x\n", safearray->fFeatures);
582c2c66affSColin Finck     ok(safearray->cbElements == sizeof(VARIANT), "safearray->cbElements = %x\n", safearray->cbElements);
583c2c66affSColin Finck     ok(!safearray->cLocks, "safearray->cLocks = %x\n", safearray->cLocks);
584c2c66affSColin Finck 
585c2c66affSColin Finck     for(i=0; i < safearray->cDims; i++) {
586c2c66affSColin Finck         ok(safearray->rgsabound[i].cElements == (indims ? i+4 : 1), "safearray->rgsabound[%d].cElements = %d\n", i,
587c2c66affSColin Finck            safearray->rgsabound[i].cElements);
588c2c66affSColin Finck         ok(!safearray->rgsabound[i].lLbound, "safearray->rgsabound[%d].lLbound = %d\n", i, safearray->rgsabound[i].lLbound);
589c2c66affSColin Finck     }
590c2c66affSColin Finck }
591c2c66affSColin Finck 
592c2c66affSColin Finck #define test_grfdex(a,b) _test_grfdex(__LINE__,a,b)
_test_grfdex(unsigned line,DWORD grfdex,DWORD expect)593c2c66affSColin Finck static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect)
594c2c66affSColin Finck {
595c2c66affSColin Finck     ok_(__FILE__,line)(grfdex == expect, "grfdex = %x, expected %x\n", grfdex, expect);
596c2c66affSColin Finck }
597c2c66affSColin Finck 
598c2c66affSColin Finck static IDispatchEx enumDisp;
599c2c66affSColin Finck 
EnumVARIANT_QueryInterface(IEnumVARIANT * iface,REFIID riid,void ** ppv)600c2c66affSColin Finck static HRESULT WINAPI EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
601c2c66affSColin Finck {
602c2c66affSColin Finck     if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumVARIANT)) {
603c2c66affSColin Finck         *ppv = iface;
604c2c66affSColin Finck         return S_OK;
605c2c66affSColin Finck     }
606c2c66affSColin Finck 
607c2c66affSColin Finck     if(IsEqualGUID(riid, &IID_IDispatch)) {
608c2c66affSColin Finck         *ppv = &enumDisp;
609c2c66affSColin Finck         return S_OK;
610c2c66affSColin Finck     }
611c2c66affSColin Finck 
612c2c66affSColin Finck     ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
613c2c66affSColin Finck     return E_NOINTERFACE;
614c2c66affSColin Finck }
615c2c66affSColin Finck 
EnumVARIANT_AddRef(IEnumVARIANT * iface)616c2c66affSColin Finck static ULONG WINAPI EnumVARIANT_AddRef(IEnumVARIANT *iface)
617c2c66affSColin Finck {
618c2c66affSColin Finck     return 2;
619c2c66affSColin Finck }
620c2c66affSColin Finck 
EnumVARIANT_Release(IEnumVARIANT * iface)621c2c66affSColin Finck static ULONG WINAPI EnumVARIANT_Release(IEnumVARIANT *iface)
622c2c66affSColin Finck {
623c2c66affSColin Finck     return 1;
624c2c66affSColin Finck }
625c2c66affSColin Finck 
626c2c66affSColin Finck static unsigned next_cnt;
627c2c66affSColin Finck 
EnumVARIANT_Next(IEnumVARIANT * iface,ULONG celt,VARIANT * rgVar,ULONG * pCeltFetched)628c2c66affSColin Finck static HRESULT WINAPI EnumVARIANT_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
629c2c66affSColin Finck {
630c2c66affSColin Finck     if(strict_dispid_check)
631c2c66affSColin Finck         CHECK_EXPECT2(Next);
632c2c66affSColin Finck 
633c2c66affSColin Finck     ok(celt == 1, "celt = %d\n", celt);
634c2c66affSColin Finck     ok(V_VT(rgVar) == VT_EMPTY, "V_VT(rgVar) = %d\n", V_VT(rgVar));
635c2c66affSColin Finck     ok(!pCeltFetched, "pCeltFetched = %p\n", pCeltFetched);
636c2c66affSColin Finck 
637c2c66affSColin Finck     if(next_cnt++ < 3) {
638c2c66affSColin Finck         V_VT(rgVar) = VT_I2;
639c2c66affSColin Finck         V_I2(rgVar) = next_cnt;
640c2c66affSColin Finck         return S_OK;
641c2c66affSColin Finck     }
642c2c66affSColin Finck 
643c2c66affSColin Finck     return S_FALSE;
644c2c66affSColin Finck }
645c2c66affSColin Finck 
EnumVARIANT_Skip(IEnumVARIANT * iface,ULONG celt)646c2c66affSColin Finck static HRESULT WINAPI EnumVARIANT_Skip(IEnumVARIANT *iface, ULONG celt)
647c2c66affSColin Finck {
648c2c66affSColin Finck     ok(0, "unexpected call\n");
649c2c66affSColin Finck     return E_NOTIMPL;
650c2c66affSColin Finck }
651c2c66affSColin Finck 
EnumVARIANT_Reset(IEnumVARIANT * iface)652c2c66affSColin Finck static HRESULT WINAPI EnumVARIANT_Reset(IEnumVARIANT *iface)
653c2c66affSColin Finck {
654c2c66affSColin Finck     ok(0, "unexpected call\n");
655c2c66affSColin Finck     return E_NOTIMPL;
656c2c66affSColin Finck }
657c2c66affSColin Finck 
EnumVARIANT_Clone(IEnumVARIANT * iface,IEnumVARIANT ** ppEnum)658c2c66affSColin Finck static HRESULT WINAPI EnumVARIANT_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
659c2c66affSColin Finck {
660c2c66affSColin Finck     ok(0, "unexpected call\n");
661c2c66affSColin Finck     return E_NOTIMPL;
662c2c66affSColin Finck }
663c2c66affSColin Finck 
664c2c66affSColin Finck static const IEnumVARIANTVtbl EnumVARIANTVtbl = {
665c2c66affSColin Finck     EnumVARIANT_QueryInterface,
666c2c66affSColin Finck     EnumVARIANT_AddRef,
667c2c66affSColin Finck     EnumVARIANT_Release,
668c2c66affSColin Finck     EnumVARIANT_Next,
669c2c66affSColin Finck     EnumVARIANT_Skip,
670c2c66affSColin Finck     EnumVARIANT_Reset,
671c2c66affSColin Finck     EnumVARIANT_Clone
672c2c66affSColin Finck };
673c2c66affSColin Finck 
674c2c66affSColin Finck static IEnumVARIANT enumObj = { &EnumVARIANTVtbl };
675c2c66affSColin Finck 
DispatchEx_QueryInterface(IDispatchEx * iface,REFIID riid,void ** ppv)676c2c66affSColin Finck static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
677c2c66affSColin Finck {
678c2c66affSColin Finck     *ppv = NULL;
679c2c66affSColin Finck 
680c2c66affSColin Finck     if(IsEqualGUID(riid, &IID_IUnknown)
681c2c66affSColin Finck        || IsEqualGUID(riid, &IID_IDispatch)
682c2c66affSColin Finck        || IsEqualGUID(riid, &IID_IDispatchEx))
683c2c66affSColin Finck         *ppv = iface;
684c2c66affSColin Finck     else {
685c2c66affSColin Finck         trace("QI %s\n", wine_dbgstr_guid(riid));
686c2c66affSColin Finck         return E_NOINTERFACE;
687c2c66affSColin Finck     }
688c2c66affSColin Finck 
689c2c66affSColin Finck     IUnknown_AddRef((IUnknown*)*ppv);
690c2c66affSColin Finck     return S_OK;
691c2c66affSColin Finck }
692c2c66affSColin Finck 
DispatchEx_AddRef(IDispatchEx * iface)693c2c66affSColin Finck static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
694c2c66affSColin Finck {
695c2c66affSColin Finck     return 2;
696c2c66affSColin Finck }
697c2c66affSColin Finck 
DispatchEx_Release(IDispatchEx * iface)698c2c66affSColin Finck static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
699c2c66affSColin Finck {
700c2c66affSColin Finck     return 1;
701c2c66affSColin Finck }
702c2c66affSColin Finck 
DispatchEx_GetTypeInfoCount(IDispatchEx * iface,UINT * pctinfo)703c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
704c2c66affSColin Finck {
705c2c66affSColin Finck     ok(0, "unexpected call\n");
706c2c66affSColin Finck     return E_NOTIMPL;
707c2c66affSColin Finck }
708c2c66affSColin Finck 
DispatchEx_GetTypeInfo(IDispatchEx * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)709c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
710c2c66affSColin Finck                                               LCID lcid, ITypeInfo **ppTInfo)
711c2c66affSColin Finck {
712c2c66affSColin Finck     return E_NOTIMPL;
713c2c66affSColin Finck }
714c2c66affSColin Finck 
DispatchEx_GetIDsOfNames(IDispatchEx * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)715c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
716c2c66affSColin Finck                                                 LPOLESTR *rgszNames, UINT cNames,
717c2c66affSColin Finck                                                 LCID lcid, DISPID *rgDispId)
718c2c66affSColin Finck {
719c2c66affSColin Finck     ok(0, "unexpected call\n");
720c2c66affSColin Finck     return E_NOTIMPL;
721c2c66affSColin Finck }
722c2c66affSColin Finck 
DispatchEx_Invoke(IDispatchEx * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)723c2c66affSColin Finck static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
724c2c66affSColin Finck                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
725c2c66affSColin Finck                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
726c2c66affSColin Finck {
727c2c66affSColin Finck     ok(0, "unexpected call\n");
728c2c66affSColin Finck     return E_NOTIMPL;
729c2c66affSColin Finck }
730c2c66affSColin Finck 
DispatchEx_DeleteMemberByName(IDispatchEx * iface,BSTR bstrName,DWORD grfdex)731c2c66affSColin Finck static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
732c2c66affSColin Finck {
733c2c66affSColin Finck     ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
734c2c66affSColin Finck     return E_NOTIMPL;
735c2c66affSColin Finck }
736c2c66affSColin Finck 
DispatchEx_DeleteMemberByDispID(IDispatchEx * iface,DISPID id)737c2c66affSColin Finck static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
738c2c66affSColin Finck {
739c2c66affSColin Finck     ok(0, "unexpected call\n");
740c2c66affSColin Finck     return E_NOTIMPL;
741c2c66affSColin Finck }
742c2c66affSColin Finck 
DispatchEx_GetMemberProperties(IDispatchEx * iface,DISPID id,DWORD grfdexFetch,DWORD * pgrfdex)743c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
744c2c66affSColin Finck {
745c2c66affSColin Finck     ok(0, "unexpected call\n");
746c2c66affSColin Finck     return E_NOTIMPL;
747c2c66affSColin Finck }
748c2c66affSColin Finck 
DispatchEx_GetMemberName(IDispatchEx * iface,DISPID id,BSTR * pbstrName)749c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
750c2c66affSColin Finck {
751c2c66affSColin Finck     ok(0, "unexpected call\n");
752c2c66affSColin Finck     return E_NOTIMPL;
753c2c66affSColin Finck }
754c2c66affSColin Finck 
DispatchEx_GetNextDispID(IDispatchEx * iface,DWORD grfdex,DISPID id,DISPID * pid)755c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
756c2c66affSColin Finck {
757c2c66affSColin Finck     ok(0, "unexpected call\n");
758c2c66affSColin Finck     return E_NOTIMPL;
759c2c66affSColin Finck }
760c2c66affSColin Finck 
DispatchEx_GetNameSpaceParent(IDispatchEx * iface,IUnknown ** ppunk)761c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
762c2c66affSColin Finck {
763c2c66affSColin Finck     ok(0, "unexpected call\n");
764c2c66affSColin Finck     return E_NOTIMPL;
765c2c66affSColin Finck }
766c2c66affSColin Finck 
DispatchEx_GetDispID(IDispatchEx * iface,BSTR bstrName,DWORD grfdex,DISPID * pid)767c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
768c2c66affSColin Finck {
769c2c66affSColin Finck     ok(0, "unexpected call\n");
770c2c66affSColin Finck     return E_NOTIMPL;
771c2c66affSColin Finck }
772c2c66affSColin Finck 
DispatchEx_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * pvarRes,EXCEPINFO * pei,IServiceProvider * pspCaller)773c2c66affSColin Finck static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
774c2c66affSColin Finck         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
775c2c66affSColin Finck {
776c2c66affSColin Finck     ok(0, "unexpected call %d\n", id);
777c2c66affSColin Finck     return E_NOTIMPL;
778c2c66affSColin Finck }
779c2c66affSColin Finck 
testObj_GetDispID(IDispatchEx * iface,BSTR bstrName,DWORD grfdex,DISPID * pid)780c2c66affSColin Finck static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
781c2c66affSColin Finck {
782*7d76303dSAmine Khaldi     typedef struct {
783*7d76303dSAmine Khaldi           const char * const name;
784*7d76303dSAmine Khaldi           DISPID pid;
785*7d76303dSAmine Khaldi           BOOL *expect;
786*7d76303dSAmine Khaldi           BOOL *called;
787*7d76303dSAmine Khaldi     } dispid_t;
788*7d76303dSAmine Khaldi 
789*7d76303dSAmine Khaldi     dispid_t dispids[] = {
790*7d76303dSAmine Khaldi        { "propget", DISPID_TESTOBJ_PROPGET, REF_EXPECT(testobj_propget_d) },
791*7d76303dSAmine Khaldi        { "propput", DISPID_TESTOBJ_PROPPUT, REF_EXPECT(testobj_propput_d) },
792*7d76303dSAmine Khaldi        { "rem", DISPID_TESTOBJ_KEYWORD, NULL },
793*7d76303dSAmine Khaldi        { "true", DISPID_TESTOBJ_KEYWORD, NULL },
794*7d76303dSAmine Khaldi        { "false", DISPID_TESTOBJ_KEYWORD, NULL },
795*7d76303dSAmine Khaldi        { "not", DISPID_TESTOBJ_KEYWORD, NULL },
796*7d76303dSAmine Khaldi        { "and", DISPID_TESTOBJ_KEYWORD, NULL },
797*7d76303dSAmine Khaldi        { "or", DISPID_TESTOBJ_KEYWORD, NULL },
798*7d76303dSAmine Khaldi        { "xor", DISPID_TESTOBJ_KEYWORD, NULL },
799*7d76303dSAmine Khaldi        { "eqv", DISPID_TESTOBJ_KEYWORD, NULL },
800*7d76303dSAmine Khaldi        { "imp", DISPID_TESTOBJ_KEYWORD, NULL },
801*7d76303dSAmine Khaldi        { "is", DISPID_TESTOBJ_KEYWORD, NULL },
802*7d76303dSAmine Khaldi        { "mod", DISPID_TESTOBJ_KEYWORD, NULL },
803*7d76303dSAmine Khaldi        { "call", DISPID_TESTOBJ_KEYWORD, NULL },
804*7d76303dSAmine Khaldi        { "dim", DISPID_TESTOBJ_KEYWORD, NULL },
805*7d76303dSAmine Khaldi        { "sub", DISPID_TESTOBJ_KEYWORD, NULL },
806*7d76303dSAmine Khaldi        { "function", DISPID_TESTOBJ_KEYWORD, NULL },
807*7d76303dSAmine Khaldi        { "get", DISPID_TESTOBJ_KEYWORD, NULL },
808*7d76303dSAmine Khaldi        { "let", DISPID_TESTOBJ_KEYWORD, NULL },
809*7d76303dSAmine Khaldi        { "const", DISPID_TESTOBJ_KEYWORD, NULL },
810*7d76303dSAmine Khaldi        { "if", DISPID_TESTOBJ_KEYWORD, NULL },
811*7d76303dSAmine Khaldi        { "else", DISPID_TESTOBJ_KEYWORD, NULL },
812*7d76303dSAmine Khaldi        { "elseif", DISPID_TESTOBJ_KEYWORD, NULL },
813*7d76303dSAmine Khaldi        { "end", DISPID_TESTOBJ_KEYWORD, NULL },
814*7d76303dSAmine Khaldi        { "then", DISPID_TESTOBJ_KEYWORD, NULL },
815*7d76303dSAmine Khaldi        { "exit", DISPID_TESTOBJ_KEYWORD, NULL },
816*7d76303dSAmine Khaldi        { "while", DISPID_TESTOBJ_KEYWORD, NULL },
817*7d76303dSAmine Khaldi        { "wend", DISPID_TESTOBJ_KEYWORD, NULL },
818*7d76303dSAmine Khaldi        { "do", DISPID_TESTOBJ_KEYWORD, NULL },
819*7d76303dSAmine Khaldi        { "loop", DISPID_TESTOBJ_KEYWORD, NULL },
820*7d76303dSAmine Khaldi        { "until", DISPID_TESTOBJ_KEYWORD, NULL },
821*7d76303dSAmine Khaldi        { "for", DISPID_TESTOBJ_KEYWORD, NULL },
822*7d76303dSAmine Khaldi        { "to", DISPID_TESTOBJ_KEYWORD, NULL },
823*7d76303dSAmine Khaldi        { "each", DISPID_TESTOBJ_KEYWORD, NULL },
824*7d76303dSAmine Khaldi        { "in", DISPID_TESTOBJ_KEYWORD, NULL },
825*7d76303dSAmine Khaldi        { "select", DISPID_TESTOBJ_KEYWORD, NULL },
826*7d76303dSAmine Khaldi        { "case", DISPID_TESTOBJ_KEYWORD, NULL },
827*7d76303dSAmine Khaldi        { "byref", DISPID_TESTOBJ_KEYWORD, NULL },
828*7d76303dSAmine Khaldi        { "byval", DISPID_TESTOBJ_KEYWORD, NULL },
829*7d76303dSAmine Khaldi        { "option", DISPID_TESTOBJ_KEYWORD, NULL },
830*7d76303dSAmine Khaldi        { "nothing", DISPID_TESTOBJ_KEYWORD, NULL },
831*7d76303dSAmine Khaldi        { "empty", DISPID_TESTOBJ_KEYWORD, NULL },
832*7d76303dSAmine Khaldi        { "null", DISPID_TESTOBJ_KEYWORD, NULL },
833*7d76303dSAmine Khaldi        { "class", DISPID_TESTOBJ_KEYWORD, NULL },
834*7d76303dSAmine Khaldi        { "set", DISPID_TESTOBJ_KEYWORD, NULL },
835*7d76303dSAmine Khaldi        { "new", DISPID_TESTOBJ_KEYWORD, NULL },
836*7d76303dSAmine Khaldi        { "public", DISPID_TESTOBJ_KEYWORD, NULL },
837*7d76303dSAmine Khaldi        { "private", DISPID_TESTOBJ_KEYWORD, NULL },
838*7d76303dSAmine Khaldi        { "next", DISPID_TESTOBJ_KEYWORD, NULL },
839*7d76303dSAmine Khaldi        { "on", DISPID_TESTOBJ_KEYWORD, NULL },
840*7d76303dSAmine Khaldi        { "resume", DISPID_TESTOBJ_KEYWORD, NULL },
841*7d76303dSAmine Khaldi        { "goto", DISPID_TESTOBJ_KEYWORD, NULL },
842*7d76303dSAmine Khaldi     };
843*7d76303dSAmine Khaldi     int i;
844*7d76303dSAmine Khaldi 
845*7d76303dSAmine Khaldi     for (i = 0; i < ARRAY_SIZE(dispids); i++) {
846*7d76303dSAmine Khaldi         if(!stricmp_wa(bstrName, dispids[i].name)) {
847*7d76303dSAmine Khaldi             dispid_t *d = &dispids[i];
848*7d76303dSAmine Khaldi             if(d->expect) {
849*7d76303dSAmine Khaldi                ok(*d->expect, "unexpected call %s\n", d->name);
850*7d76303dSAmine Khaldi                *d->called = TRUE;
851*7d76303dSAmine Khaldi                *d->expect = FALSE;
852*7d76303dSAmine Khaldi             }
853c2c66affSColin Finck             test_grfdex(grfdex, fdexNameCaseInsensitive);
854*7d76303dSAmine Khaldi             *pid = d->pid;
855c2c66affSColin Finck             return S_OK;
856c2c66affSColin Finck         }
857c2c66affSColin Finck     }
858c2c66affSColin Finck 
859c2c66affSColin Finck     ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
860c2c66affSColin Finck     return DISP_E_UNKNOWNNAME;
861c2c66affSColin Finck }
862c2c66affSColin Finck 
testObj_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * pvarRes,EXCEPINFO * pei,IServiceProvider * pspCaller)863c2c66affSColin Finck static HRESULT WINAPI testObj_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
864c2c66affSColin Finck         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
865c2c66affSColin Finck {
866c2c66affSColin Finck     switch(id) {
867c2c66affSColin Finck     case DISPID_VALUE: {
868c2c66affSColin Finck         VARIANT *arg;
869c2c66affSColin Finck         int i;
870c2c66affSColin Finck 
871c2c66affSColin Finck         CHECK_EXPECT(testobj_value_i);
872c2c66affSColin Finck 
873c2c66affSColin Finck         ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
874c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
875c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
876c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
877c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
878c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
879c2c66affSColin Finck 
880c2c66affSColin Finck         for(i=0; i<pdp->cArgs; i++) {
881c2c66affSColin Finck             arg = pdp->rgvarg+pdp->cArgs-i-1;
882c2c66affSColin Finck             ok(V_VT(arg) == VT_I2, "V_VT(arg) = %d\n", V_VT(arg));
883c2c66affSColin Finck             ok(V_I2(arg) == i+1, "V_I2(arg) = %d\n", V_I2(arg));
884c2c66affSColin Finck         }
885c2c66affSColin Finck 
886c2c66affSColin Finck         V_VT(pvarRes) = VT_I2;
887c2c66affSColin Finck         V_I2(pvarRes) = pdp->cArgs;
888c2c66affSColin Finck         return S_OK;
889c2c66affSColin Finck     }
890c2c66affSColin Finck     case DISPID_TESTOBJ_PROPGET:
891c2c66affSColin Finck         CHECK_EXPECT(testobj_propget_i);
892c2c66affSColin Finck 
893c2c66affSColin Finck         ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
894c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
895c2c66affSColin Finck         ok(!pdp->rgvarg, "rgvarg == NULL\n");
896c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
897c2c66affSColin Finck         ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
898c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
899c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
900c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
901c2c66affSColin Finck 
902c2c66affSColin Finck         V_VT(pvarRes) = VT_I2;
903c2c66affSColin Finck         V_I2(pvarRes) = 10;
904c2c66affSColin Finck         return S_OK;
905c2c66affSColin Finck     case DISPID_TESTOBJ_PROPPUT:
906c2c66affSColin Finck         CHECK_EXPECT(testobj_propput_i);
907c2c66affSColin Finck 
908c2c66affSColin Finck         ok(wFlags == DISPATCH_PROPERTYPUT, "wFlags = %x\n", wFlags);
909c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
910c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
911c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
912c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
913c2c66affSColin Finck         ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
914c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
915c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
916c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
917c2c66affSColin Finck 
918c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_I2, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
919c2c66affSColin Finck         ok(V_I2(pdp->rgvarg) == 1, "V_I2(psp->rgvargs) = %d\n", V_I2(pdp->rgvarg));
920c2c66affSColin Finck         return S_OK;
921*7d76303dSAmine Khaldi 
922*7d76303dSAmine Khaldi     case DISPID_TESTOBJ_KEYWORD:
923*7d76303dSAmine Khaldi         V_VT(pvarRes) = VT_I2;
924*7d76303dSAmine Khaldi         V_I2(pvarRes) = 10;
925*7d76303dSAmine Khaldi         return S_OK;
926c2c66affSColin Finck     }
927c2c66affSColin Finck 
928c2c66affSColin Finck     ok(0, "unexpected call %d\n", id);
929c2c66affSColin Finck     return E_FAIL;
930c2c66affSColin Finck }
931c2c66affSColin Finck 
932c2c66affSColin Finck static IDispatchExVtbl testObjVtbl = {
933c2c66affSColin Finck     DispatchEx_QueryInterface,
934c2c66affSColin Finck     DispatchEx_AddRef,
935c2c66affSColin Finck     DispatchEx_Release,
936c2c66affSColin Finck     DispatchEx_GetTypeInfoCount,
937c2c66affSColin Finck     DispatchEx_GetTypeInfo,
938c2c66affSColin Finck     DispatchEx_GetIDsOfNames,
939c2c66affSColin Finck     DispatchEx_Invoke,
940c2c66affSColin Finck     testObj_GetDispID,
941c2c66affSColin Finck     testObj_InvokeEx,
942c2c66affSColin Finck     DispatchEx_DeleteMemberByName,
943c2c66affSColin Finck     DispatchEx_DeleteMemberByDispID,
944c2c66affSColin Finck     DispatchEx_GetMemberProperties,
945c2c66affSColin Finck     DispatchEx_GetMemberName,
946c2c66affSColin Finck     DispatchEx_GetNextDispID,
947c2c66affSColin Finck     DispatchEx_GetNameSpaceParent
948c2c66affSColin Finck };
949c2c66affSColin Finck 
950c2c66affSColin Finck static IDispatchEx testObj = { &testObjVtbl };
951c2c66affSColin Finck 
enumDisp_QueryInterface(IDispatchEx * iface,REFIID riid,void ** ppv)952c2c66affSColin Finck static HRESULT WINAPI enumDisp_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
953c2c66affSColin Finck {
954c2c66affSColin Finck     return IEnumVARIANT_QueryInterface(&enumObj, riid, ppv);
955c2c66affSColin Finck }
956c2c66affSColin Finck 
957c2c66affSColin Finck static IDispatchExVtbl enumDispVtbl = {
958c2c66affSColin Finck     enumDisp_QueryInterface,
959c2c66affSColin Finck     DispatchEx_AddRef,
960c2c66affSColin Finck     DispatchEx_Release,
961c2c66affSColin Finck     DispatchEx_GetTypeInfoCount,
962c2c66affSColin Finck     DispatchEx_GetTypeInfo,
963c2c66affSColin Finck     DispatchEx_GetIDsOfNames,
964c2c66affSColin Finck     DispatchEx_Invoke,
965c2c66affSColin Finck     DispatchEx_GetDispID,
966c2c66affSColin Finck     DispatchEx_InvokeEx,
967c2c66affSColin Finck     DispatchEx_DeleteMemberByName,
968c2c66affSColin Finck     DispatchEx_DeleteMemberByDispID,
969c2c66affSColin Finck     DispatchEx_GetMemberProperties,
970c2c66affSColin Finck     DispatchEx_GetMemberName,
971c2c66affSColin Finck     DispatchEx_GetNextDispID,
972c2c66affSColin Finck     DispatchEx_GetNameSpaceParent
973c2c66affSColin Finck };
974c2c66affSColin Finck 
975c2c66affSColin Finck static IDispatchEx enumDisp = { &enumDispVtbl };
976c2c66affSColin Finck 
collectionObj_GetDispID(IDispatchEx * iface,BSTR bstrName,DWORD grfdex,DISPID * pid)977c2c66affSColin Finck static HRESULT WINAPI collectionObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
978c2c66affSColin Finck {
979c2c66affSColin Finck     if(!strcmp_wa(bstrName, "reset")) {
980c2c66affSColin Finck         *pid = DISPID_COLLOBJ_RESET;
981c2c66affSColin Finck         return S_OK;
982c2c66affSColin Finck     }
983c2c66affSColin Finck 
984c2c66affSColin Finck     ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
985c2c66affSColin Finck     return DISP_E_UNKNOWNNAME;
986c2c66affSColin Finck }
987c2c66affSColin Finck 
collectionObj_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * pvarRes,EXCEPINFO * pei,IServiceProvider * pspCaller)988c2c66affSColin Finck static HRESULT WINAPI collectionObj_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
989c2c66affSColin Finck         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
990c2c66affSColin Finck {
991c2c66affSColin Finck     switch(id) {
992c2c66affSColin Finck     case DISPID_NEWENUM:
993c2c66affSColin Finck         if(strict_dispid_check)
994c2c66affSColin Finck             CHECK_EXPECT(collectionobj_newenum_i);
995c2c66affSColin Finck 
996c2c66affSColin Finck         ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
997c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
998c2c66affSColin Finck         ok(!pdp->rgvarg, "rgvarg == NULL\n");
999c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1000c2c66affSColin Finck         ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1001c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1002c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1003c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1004c2c66affSColin Finck 
1005c2c66affSColin Finck         V_VT(pvarRes) = VT_UNKNOWN;
1006c2c66affSColin Finck         V_UNKNOWN(pvarRes) = (IUnknown*)&enumObj;
1007c2c66affSColin Finck         return S_OK;
1008c2c66affSColin Finck     case DISPID_COLLOBJ_RESET:
1009c2c66affSColin Finck         next_cnt = 0;
1010c2c66affSColin Finck         return S_OK;
1011c2c66affSColin Finck     }
1012c2c66affSColin Finck 
1013c2c66affSColin Finck     ok(0, "unexpected call %d\n", id);
1014c2c66affSColin Finck     return E_NOTIMPL;
1015c2c66affSColin Finck }
1016c2c66affSColin Finck 
1017c2c66affSColin Finck static IDispatchExVtbl collectionObjVtbl = {
1018c2c66affSColin Finck     DispatchEx_QueryInterface,
1019c2c66affSColin Finck     DispatchEx_AddRef,
1020c2c66affSColin Finck     DispatchEx_Release,
1021c2c66affSColin Finck     DispatchEx_GetTypeInfoCount,
1022c2c66affSColin Finck     DispatchEx_GetTypeInfo,
1023c2c66affSColin Finck     DispatchEx_GetIDsOfNames,
1024c2c66affSColin Finck     DispatchEx_Invoke,
1025c2c66affSColin Finck     collectionObj_GetDispID,
1026c2c66affSColin Finck     collectionObj_InvokeEx,
1027c2c66affSColin Finck     DispatchEx_DeleteMemberByName,
1028c2c66affSColin Finck     DispatchEx_DeleteMemberByDispID,
1029c2c66affSColin Finck     DispatchEx_GetMemberProperties,
1030c2c66affSColin Finck     DispatchEx_GetMemberName,
1031c2c66affSColin Finck     DispatchEx_GetNextDispID,
1032c2c66affSColin Finck     DispatchEx_GetNameSpaceParent
1033c2c66affSColin Finck };
1034c2c66affSColin Finck 
1035c2c66affSColin Finck static IDispatchEx collectionObj = { &collectionObjVtbl };
1036c2c66affSColin Finck 
1037c2c66affSColin Finck static ULONG refobj_ref;
1038c2c66affSColin Finck 
RefObj_AddRef(IDispatchEx * iface)1039c2c66affSColin Finck static ULONG WINAPI RefObj_AddRef(IDispatchEx *iface)
1040c2c66affSColin Finck {
1041c2c66affSColin Finck     return ++refobj_ref;
1042c2c66affSColin Finck }
1043c2c66affSColin Finck 
RefObj_Release(IDispatchEx * iface)1044c2c66affSColin Finck static ULONG WINAPI RefObj_Release(IDispatchEx *iface)
1045c2c66affSColin Finck {
1046c2c66affSColin Finck     return --refobj_ref;
1047c2c66affSColin Finck }
1048c2c66affSColin Finck 
1049c2c66affSColin Finck static IDispatchExVtbl RefObjVtbl = {
1050c2c66affSColin Finck     DispatchEx_QueryInterface,
1051c2c66affSColin Finck     RefObj_AddRef,
1052c2c66affSColin Finck     RefObj_Release,
1053c2c66affSColin Finck     DispatchEx_GetTypeInfoCount,
1054c2c66affSColin Finck     DispatchEx_GetTypeInfo,
1055c2c66affSColin Finck     DispatchEx_GetIDsOfNames,
1056c2c66affSColin Finck     DispatchEx_Invoke,
1057c2c66affSColin Finck     DispatchEx_GetDispID,
1058c2c66affSColin Finck     DispatchEx_InvokeEx,
1059c2c66affSColin Finck     DispatchEx_DeleteMemberByName,
1060c2c66affSColin Finck     DispatchEx_DeleteMemberByDispID,
1061c2c66affSColin Finck     DispatchEx_GetMemberProperties,
1062c2c66affSColin Finck     DispatchEx_GetMemberName,
1063c2c66affSColin Finck     DispatchEx_GetNextDispID,
1064c2c66affSColin Finck     DispatchEx_GetNameSpaceParent
1065c2c66affSColin Finck };
1066c2c66affSColin Finck 
1067c2c66affSColin Finck static IDispatchEx RefObj = { &RefObjVtbl };
1068c2c66affSColin Finck 
1069c78e8736SAmine Khaldi static ULONG global_ref;
1070c78e8736SAmine Khaldi 
Global_AddRef(IDispatchEx * iface)1071c78e8736SAmine Khaldi static ULONG WINAPI Global_AddRef(IDispatchEx *iface)
1072c78e8736SAmine Khaldi {
1073c78e8736SAmine Khaldi     return ++global_ref;
1074c78e8736SAmine Khaldi }
1075c78e8736SAmine Khaldi 
Global_Release(IDispatchEx * iface)1076c78e8736SAmine Khaldi static ULONG WINAPI Global_Release(IDispatchEx *iface)
1077c78e8736SAmine Khaldi {
1078c78e8736SAmine Khaldi     return --global_ref;
1079c78e8736SAmine Khaldi }
1080c78e8736SAmine Khaldi 
Global_GetDispID(IDispatchEx * iface,BSTR bstrName,DWORD grfdex,DISPID * pid)1081c2c66affSColin Finck static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1082c2c66affSColin Finck {
1083c2c66affSColin Finck     if(!strcmp_wa(bstrName, "ok")) {
1084c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1085c2c66affSColin Finck         *pid = DISPID_GLOBAL_OK;
1086c2c66affSColin Finck         return S_OK;
1087c2c66affSColin Finck     }
1088942c4265SAmine Khaldi     if(!strcmp_wa(bstrName, "todo_wine_ok")) {
1089942c4265SAmine Khaldi         test_grfdex(grfdex, fdexNameCaseInsensitive);
1090942c4265SAmine Khaldi         *pid = DISPID_GLOBAL_TODO_WINE_OK;
1091942c4265SAmine Khaldi         return S_OK;
1092942c4265SAmine Khaldi     }
1093c2c66affSColin Finck     if(!strcmp_wa(bstrName, "trace")) {
1094c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1095c2c66affSColin Finck         *pid = DISPID_GLOBAL_TRACE;
1096c2c66affSColin Finck         return S_OK;
1097c2c66affSColin Finck     }
1098c2c66affSColin Finck     if(!strcmp_wa(bstrName, "reportSuccess")) {
1099c2c66affSColin Finck         CHECK_EXPECT(global_success_d);
1100c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1101c2c66affSColin Finck         *pid = DISPID_GLOBAL_REPORTSUCCESS;
1102c2c66affSColin Finck         return S_OK;
1103c2c66affSColin Finck     }
1104c2c66affSColin Finck     if(!strcmp_wa(bstrName, "getVT")) {
1105c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1106c2c66affSColin Finck         *pid = DISPID_GLOBAL_GETVT;
1107c2c66affSColin Finck         return S_OK;
1108c2c66affSColin Finck     }
1109c2c66affSColin Finck     if(!strcmp_wa(bstrName, "isEnglishLang")) {
1110c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1111c2c66affSColin Finck         *pid = DISPID_GLOBAL_ISENGLANG;
1112c2c66affSColin Finck         return S_OK;
1113c2c66affSColin Finck     }
1114942c4265SAmine Khaldi     if(!strcmp_wa(bstrName, "firstDayOfWeek")) {
1115942c4265SAmine Khaldi         test_grfdex(grfdex, fdexNameCaseInsensitive);
1116942c4265SAmine Khaldi         *pid = DISPID_GLOBAL_WEEKSTARTDAY;
1117942c4265SAmine Khaldi         return S_OK;
1118942c4265SAmine Khaldi     }
1119*7d76303dSAmine Khaldi     if(!strcmp_wa(bstrName, "globalCallback")) {
1120*7d76303dSAmine Khaldi         test_grfdex(grfdex, fdexNameCaseInsensitive);
1121*7d76303dSAmine Khaldi         *pid = DISPID_GLOBAL_GLOBALCALLBACK;
1122*7d76303dSAmine Khaldi         return S_OK;
1123*7d76303dSAmine Khaldi     }
1124c2c66affSColin Finck     if(!strcmp_wa(bstrName, "testObj")) {
1125c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1126c2c66affSColin Finck         *pid = DISPID_GLOBAL_TESTOBJ;
1127c2c66affSColin Finck         return S_OK;
1128c2c66affSColin Finck     }
1129c2c66affSColin Finck     if(!strcmp_wa(bstrName, "collectionObj")) {
1130c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1131c2c66affSColin Finck         *pid = DISPID_GLOBAL_COLLOBJ;
1132c2c66affSColin Finck         return S_OK;
1133c2c66affSColin Finck     }
1134c2c66affSColin Finck     if(!strcmp_wa(bstrName, "vbvar")) {
1135c2c66affSColin Finck         CHECK_EXPECT(global_vbvar_d);
1136c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1137c2c66affSColin Finck         *pid = DISPID_GLOBAL_VBVAR;
1138c2c66affSColin Finck         return S_OK;
1139c2c66affSColin Finck     }
1140c2c66affSColin Finck     if(!strcmp_wa(bstrName, "letobj")) {
1141c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1142c2c66affSColin Finck         *pid = DISPID_GLOBAL_LETOBJ;
1143c2c66affSColin Finck         return S_OK;
1144c2c66affSColin Finck     }
1145c2c66affSColin Finck     if(!strcmp_wa(bstrName, "setobj")) {
1146c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1147c2c66affSColin Finck         *pid = DISPID_GLOBAL_SETOBJ;
1148c2c66affSColin Finck         return S_OK;
1149c2c66affSColin Finck     }
1150c2c66affSColin Finck     if(!strcmp_wa(bstrName, "isNullDisp")) {
1151c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1152c2c66affSColin Finck         *pid = DISPID_GLOBAL_ISNULLDISP;
1153c2c66affSColin Finck         return S_OK;
1154c2c66affSColin Finck     }
1155c2c66affSColin Finck     if(!strcmp_wa(bstrName, "testDisp")) {
1156c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1157c2c66affSColin Finck         *pid = DISPID_GLOBAL_TESTDISP;
1158c2c66affSColin Finck         return S_OK;
1159c2c66affSColin Finck     }
1160c2c66affSColin Finck     if(!strcmp_wa(bstrName, "RefObj")) {
1161c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1162c2c66affSColin Finck         *pid = DISPID_GLOBAL_REFOBJ;
1163c2c66affSColin Finck         return S_OK;
1164c2c66affSColin Finck     }
1165c2c66affSColin Finck     if(!strcmp_wa(bstrName, "propargput")) {
1166c2c66affSColin Finck         CHECK_EXPECT(global_propargput_d);
1167c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1168c2c66affSColin Finck         *pid = DISPID_GLOBAL_PROPARGPUT;
1169c2c66affSColin Finck         return S_OK;
1170c2c66affSColin Finck     }
1171c2c66affSColin Finck     if(!strcmp_wa(bstrName, "propargput1")) {
1172c2c66affSColin Finck         CHECK_EXPECT(global_propargput1_d);
1173c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1174c2c66affSColin Finck         *pid = DISPID_GLOBAL_PROPARGPUT1;
1175c2c66affSColin Finck         return S_OK;
1176c2c66affSColin Finck     }
1177c2c66affSColin Finck     if(!strcmp_wa(bstrName, "counter")) {
1178c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1179c2c66affSColin Finck         *pid = DISPID_GLOBAL_COUNTER;
1180c2c66affSColin Finck         return S_OK;
1181c2c66affSColin Finck     }
1182c2c66affSColin Finck     if(!strcmp_wa(bstrName, "doubleAsString")) {
1183c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1184c2c66affSColin Finck         *pid = DISPID_GLOBAL_DOUBLEASSTRING;
1185c2c66affSColin Finck         return S_OK;
1186c2c66affSColin Finck     }
1187c2c66affSColin Finck     if(!strcmp_wa(bstrName, "testArray")) {
1188c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1189c2c66affSColin Finck         *pid = DISPID_GLOBAL_TESTARRAY;
1190c2c66affSColin Finck         return S_OK;
1191c2c66affSColin Finck     }
1192c2c66affSColin Finck     if(!strcmp_wa(bstrName, "throwInt")) {
1193c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1194c2c66affSColin Finck         *pid = DISPID_GLOBAL_THROWINT;
1195c2c66affSColin Finck         return S_OK;
1196c2c66affSColin Finck     }
1197c2c66affSColin Finck     if(!strcmp_wa(bstrName, "testOptionalArg")) {
1198c2c66affSColin Finck         test_grfdex(grfdex, fdexNameCaseInsensitive);
1199c2c66affSColin Finck         *pid = DISPID_GLOBAL_TESTOPTIONALARG;
1200c2c66affSColin Finck         return S_OK;
1201c2c66affSColin Finck     }
1202*7d76303dSAmine Khaldi     if(!strcmp_wa(bstrName, "testErrorObject")) {
1203*7d76303dSAmine Khaldi         test_grfdex(grfdex, fdexNameCaseInsensitive);
1204*7d76303dSAmine Khaldi         *pid = DISPID_GLOBAL_TESTERROROBJECT;
1205*7d76303dSAmine Khaldi         return S_OK;
1206*7d76303dSAmine Khaldi     }
1207c2c66affSColin Finck 
1208c2c66affSColin Finck     if(strict_dispid_check && strcmp_wa(bstrName, "x"))
1209c2c66affSColin Finck         ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
1210c2c66affSColin Finck     return DISP_E_UNKNOWNNAME;
1211c2c66affSColin Finck }
1212c2c66affSColin Finck 
Global_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * pvarRes,EXCEPINFO * pei,IServiceProvider * pspCaller)1213c2c66affSColin Finck static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1214c2c66affSColin Finck         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1215c2c66affSColin Finck {
1216c2c66affSColin Finck     switch(id) {
1217942c4265SAmine Khaldi     case DISPID_GLOBAL_TODO_WINE_OK:
1218c2c66affSColin Finck     case DISPID_GLOBAL_OK: {
1219c2c66affSColin Finck         VARIANT *b;
1220c2c66affSColin Finck 
1221c2c66affSColin Finck         ok(wFlags == INVOKE_FUNC || wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags);
1222c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1223c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1224c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1225c2c66affSColin Finck         ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
1226c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1227c2c66affSColin Finck         if(wFlags & INVOKE_PROPERTYGET)
1228c2c66affSColin Finck             ok(pvarRes != NULL, "pvarRes == NULL\n");
1229c2c66affSColin Finck         else
1230c2c66affSColin Finck             ok(!pvarRes, "pvarRes != NULL\n");
1231c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1232c2c66affSColin Finck 
1233c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1234c2c66affSColin Finck 
1235c2c66affSColin Finck         b = pdp->rgvarg+1;
1236c2c66affSColin Finck         if(V_VT(b) == (VT_BYREF|VT_VARIANT))
1237c2c66affSColin Finck             b = V_BYREF(b);
1238c2c66affSColin Finck 
1239c2c66affSColin Finck         ok(V_VT(b) == VT_BOOL, "V_VT(b) = %d\n", V_VT(b));
1240c2c66affSColin Finck 
1241942c4265SAmine Khaldi         todo_wine_if(id == DISPID_GLOBAL_TODO_WINE_OK)
1242c2c66affSColin Finck             ok(V_BOOL(b), "%s: %s\n", test_name, wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
1243c2c66affSColin Finck         return S_OK;
1244c2c66affSColin Finck     }
1245c2c66affSColin Finck 
1246c2c66affSColin Finck     case DISPID_GLOBAL_TRACE:
1247c2c66affSColin Finck         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1248c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1249c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1250c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1251c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1252c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1253c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1254c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1255c2c66affSColin Finck 
1256c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1257c2c66affSColin Finck         if(V_VT(pdp->rgvarg) == VT_BSTR)
1258c2c66affSColin Finck             trace("%s: %s\n", test_name, wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
1259c2c66affSColin Finck 
1260c2c66affSColin Finck         return S_OK;
1261c2c66affSColin Finck 
1262c2c66affSColin Finck     case DISPID_GLOBAL_REPORTSUCCESS:
1263c2c66affSColin Finck         CHECK_EXPECT(global_success_i);
1264c2c66affSColin Finck 
1265c2c66affSColin Finck         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1266c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1267c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1268c2c66affSColin Finck         ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
1269c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1270c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1271c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1272c2c66affSColin Finck 
1273c2c66affSColin Finck         return S_OK;
1274c2c66affSColin Finck 
1275c2c66affSColin Finck     case DISPID_GLOBAL_GETVT:
1276c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1277c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1278c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1279c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1280c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1281c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1282c2c66affSColin Finck         ok(V_VT(pvarRes) ==  VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1283c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1284c2c66affSColin Finck 
1285c2c66affSColin Finck         V_VT(pvarRes) = VT_BSTR;
1286c2c66affSColin Finck         V_BSTR(pvarRes) = a2bstr(vt2a(pdp->rgvarg));
1287c2c66affSColin Finck         return S_OK;
1288c2c66affSColin Finck 
1289c2c66affSColin Finck     case DISPID_GLOBAL_ISENGLANG:
1290c2c66affSColin Finck         ok(wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags);
1291c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1292c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1293c2c66affSColin Finck         ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
1294c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1295c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1296c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1297c2c66affSColin Finck 
1298c2c66affSColin Finck         V_VT(pvarRes) = VT_BOOL;
1299c2c66affSColin Finck         V_BOOL(pvarRes) = is_english ? VARIANT_TRUE : VARIANT_FALSE;
1300c2c66affSColin Finck         return S_OK;
1301c2c66affSColin Finck 
1302942c4265SAmine Khaldi     case DISPID_GLOBAL_WEEKSTARTDAY:
1303942c4265SAmine Khaldi         V_VT(pvarRes) = VT_I4;
1304942c4265SAmine Khaldi         V_I4(pvarRes) = first_day_of_week;
1305942c4265SAmine Khaldi         return S_OK;
1306942c4265SAmine Khaldi 
1307c2c66affSColin Finck     case DISPID_GLOBAL_VBVAR:
1308c2c66affSColin Finck         CHECK_EXPECT(global_vbvar_i);
1309c2c66affSColin Finck 
1310c2c66affSColin Finck         ok(wFlags == DISPATCH_PROPERTYPUT, "wFlags = %x\n", wFlags);
1311c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1312c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1313c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1314c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1315c2c66affSColin Finck         ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1316c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1317c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1318c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1319c2c66affSColin Finck 
1320c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_I2, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1321c2c66affSColin Finck         ok(V_I2(pdp->rgvarg) == 3, "V_I2(psp->rgvargs) = %d\n", V_I2(pdp->rgvarg));
1322c2c66affSColin Finck         return S_OK;
1323c2c66affSColin Finck 
1324c2c66affSColin Finck     case DISPID_GLOBAL_LETOBJ:
1325c2c66affSColin Finck         CHECK_EXPECT(global_letobj_i);
1326c2c66affSColin Finck 
1327c2c66affSColin Finck         ok(wFlags == DISPATCH_PROPERTYPUT, "wFlags = %x\n", wFlags);
1328c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1329c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1330c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1331c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1332c2c66affSColin Finck         ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1333c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1334c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1335c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1336c2c66affSColin Finck 
1337c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1338c2c66affSColin Finck         ok(V_DISPATCH(pdp->rgvarg) == (IDispatch*)&testObj, "V_DISPATCH(psp->rgvargs) != testObj\n");
1339c2c66affSColin Finck         return S_OK;
1340c2c66affSColin Finck 
1341c2c66affSColin Finck     case DISPID_GLOBAL_SETOBJ:
1342c2c66affSColin Finck         CHECK_EXPECT(global_setobj_i);
1343c2c66affSColin Finck 
1344c2c66affSColin Finck         ok(wFlags == DISPATCH_PROPERTYPUTREF, "wFlags = %x\n", wFlags);
1345c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1346c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1347c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1348c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1349c2c66affSColin Finck         ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1350c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1351c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1352c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1353c2c66affSColin Finck 
1354c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1355c2c66affSColin Finck         ok(V_DISPATCH(pdp->rgvarg) == (IDispatch*)&testObj, "V_DISPATCH(psp->rgvargs) != testObj\n");
1356c2c66affSColin Finck         return S_OK;
1357c2c66affSColin Finck 
1358c2c66affSColin Finck     case DISPID_GLOBAL_TESTOBJ:
1359c2c66affSColin Finck         ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
1360c2c66affSColin Finck 
1361c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1362c2c66affSColin Finck         ok(!pdp->rgvarg, "rgvarg != NULL\n");
1363c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1364c2c66affSColin Finck         ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1365c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1366c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1367c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1368c2c66affSColin Finck 
1369c2c66affSColin Finck         V_VT(pvarRes) = VT_DISPATCH;
1370c2c66affSColin Finck         V_DISPATCH(pvarRes) = (IDispatch*)&testObj;
1371c2c66affSColin Finck         return S_OK;
1372c2c66affSColin Finck 
1373c2c66affSColin Finck     case DISPID_GLOBAL_COLLOBJ:
1374c2c66affSColin Finck         ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
1375c2c66affSColin Finck 
1376c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1377c2c66affSColin Finck         ok(!pdp->rgvarg, "rgvarg != NULL\n");
1378c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1379c2c66affSColin Finck         ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1380c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1381c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1382c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1383c2c66affSColin Finck 
1384c2c66affSColin Finck         V_VT(pvarRes) = VT_DISPATCH;
1385c2c66affSColin Finck         V_DISPATCH(pvarRes) = (IDispatch*)&collectionObj;
1386c2c66affSColin Finck         return S_OK;
1387c2c66affSColin Finck 
1388c2c66affSColin Finck     case DISPID_GLOBAL_REFOBJ:
1389c2c66affSColin Finck         ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
1390c2c66affSColin Finck 
1391c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1392c2c66affSColin Finck         ok(!pdp->rgvarg, "rgvarg == NULL\n");
1393c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1394c2c66affSColin Finck         ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1395c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1396c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1397c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1398c2c66affSColin Finck 
1399c2c66affSColin Finck         IDispatchEx_AddRef(&RefObj);
1400c2c66affSColin Finck         V_VT(pvarRes) = VT_DISPATCH;
1401c2c66affSColin Finck         V_DISPATCH(pvarRes) = (IDispatch*)&RefObj;
1402c2c66affSColin Finck         return S_OK;
1403c2c66affSColin Finck 
1404c2c66affSColin Finck     case DISPID_GLOBAL_ISNULLDISP: {
1405c2c66affSColin Finck         VARIANT *v;
1406c2c66affSColin Finck 
1407c2c66affSColin Finck         ok(wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags);
1408c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1409c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1410c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1411c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1412c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1413c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1414c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1415c2c66affSColin Finck 
1416c2c66affSColin Finck         v = pdp->rgvarg;
1417c2c66affSColin Finck         if(V_VT(v) == (VT_VARIANT|VT_BYREF))
1418c2c66affSColin Finck             v = V_VARIANTREF(v);
1419c2c66affSColin Finck 
1420c2c66affSColin Finck         ok(V_VT(v) == VT_DISPATCH, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1421c2c66affSColin Finck         V_VT(pvarRes) = VT_BOOL;
1422c2c66affSColin Finck         V_BOOL(pvarRes) = V_DISPATCH(v) ? VARIANT_FALSE : VARIANT_TRUE;
1423c2c66affSColin Finck         return S_OK;
1424c2c66affSColin Finck     }
1425c2c66affSColin Finck 
1426c2c66affSColin Finck     case DISPID_GLOBAL_TESTDISP:
1427c2c66affSColin Finck         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1428c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1429c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1430c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1431c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1432c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1433c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1434c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1435c2c66affSColin Finck 
1436c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1437c2c66affSColin Finck         test_disp(V_DISPATCH(pdp->rgvarg));
1438c2c66affSColin Finck         return S_OK;
1439c2c66affSColin Finck 
1440c2c66affSColin Finck     case DISPID_GLOBAL_PROPARGPUT:
1441c2c66affSColin Finck         CHECK_EXPECT(global_propargput_i);
1442c2c66affSColin Finck 
1443c2c66affSColin Finck         ok(wFlags == DISPATCH_PROPERTYPUT, "wFlags = %x\n", wFlags);
1444c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1445c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1446c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1447c2c66affSColin Finck         ok(pdp->cArgs == 3, "cArgs = %d\n", pdp->cArgs);
1448c2c66affSColin Finck         ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1449c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1450c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1451c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1452c2c66affSColin Finck 
1453c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_I2, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1454c2c66affSColin Finck         ok(V_I2(pdp->rgvarg) == 0, "V_I2(psp->rgvargs) = %d\n", V_I2(pdp->rgvarg));
1455c2c66affSColin Finck 
1456c2c66affSColin Finck         ok(V_VT(pdp->rgvarg+1) == VT_I2, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp->rgvarg+1));
1457c2c66affSColin Finck         ok(V_I2(pdp->rgvarg+1) == 2, "V_I2(psp->rgvargs+1) = %d\n", V_I2(pdp->rgvarg+1));
1458c2c66affSColin Finck 
1459c2c66affSColin Finck         ok(V_VT(pdp->rgvarg+2) == VT_I2, "V_VT(psp->rgvargs+2) = %d\n", V_VT(pdp->rgvarg+2));
1460c2c66affSColin Finck         ok(V_I2(pdp->rgvarg+2) == 1, "V_I2(psp->rgvargs+2) = %d\n", V_I2(pdp->rgvarg+2));
1461c2c66affSColin Finck         return S_OK;
1462c2c66affSColin Finck 
1463c2c66affSColin Finck     case DISPID_GLOBAL_PROPARGPUT1:
1464c2c66affSColin Finck         CHECK_EXPECT(global_propargput1_i);
1465c2c66affSColin Finck 
1466c2c66affSColin Finck         ok(wFlags == DISPATCH_PROPERTYPUT, "wFlags = %x\n", wFlags);
1467c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1468c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1469c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1470c2c66affSColin Finck         ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
1471c2c66affSColin Finck         ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1472c2c66affSColin Finck         ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1473c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1474c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1475c2c66affSColin Finck 
1476c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_I2, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1477c2c66affSColin Finck         ok(V_I2(pdp->rgvarg) == 0, "V_I2(psp->rgvargs) = %d\n", V_I2(pdp->rgvarg));
1478c2c66affSColin Finck 
1479c2c66affSColin Finck         ok(V_VT(pdp->rgvarg+1) == VT_I2, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp->rgvarg+1));
1480c2c66affSColin Finck         ok(V_I2(pdp->rgvarg+1) == 1, "V_I2(psp->rgvargs+1) = %d\n", V_I2(pdp->rgvarg+1));
1481c2c66affSColin Finck 
1482c2c66affSColin Finck         return S_OK;
1483c2c66affSColin Finck 
1484c2c66affSColin Finck     case DISPID_GLOBAL_COUNTER:
1485c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1486c2c66affSColin Finck         todo_wine ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1487c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1488c2c66affSColin Finck         ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1489c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1490c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1491c2c66affSColin Finck         ok(V_VT(pvarRes) ==  VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1492c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1493c2c66affSColin Finck 
1494c2c66affSColin Finck         V_VT(pvarRes) = VT_I2;
1495c2c66affSColin Finck         V_I2(pvarRes) = test_counter++;
1496c2c66affSColin Finck         return S_OK;
1497c2c66affSColin Finck 
1498c2c66affSColin Finck     case DISPID_GLOBAL_DOUBLEASSTRING:
1499c2c66affSColin Finck         ok(wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags);
1500c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1501c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_R8, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1502c2c66affSColin Finck         ok(pvarRes != NULL, "pvarRes == NULL\n");
1503c2c66affSColin Finck 
1504c2c66affSColin Finck         V_VT(pvarRes) = VT_BSTR;
1505c2c66affSColin Finck         return VarBstrFromR8(V_R8(pdp->rgvarg), 0, 0, &V_BSTR(pvarRes));
1506c2c66affSColin Finck 
1507c2c66affSColin Finck     case DISPID_GLOBAL_TESTARRAY:
1508c2c66affSColin Finck         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1509c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1510c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1511c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1512c2c66affSColin Finck         ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
1513c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1514c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1515c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1516c2c66affSColin Finck 
1517c2c66affSColin Finck         ok(V_VT(pdp->rgvarg+1) == VT_I2, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp->rgvarg+1));
1518c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
1519c2c66affSColin Finck         ok(V_VT(V_VARIANTREF(pdp->rgvarg)) == (VT_ARRAY|VT_BYREF|VT_VARIANT),
1520c2c66affSColin Finck            "V_VT(V_VARIANTREF(psp->rgvargs)) = %d\n", V_VT(V_VARIANTREF(pdp->rgvarg)));
1521c2c66affSColin Finck         if(V_I2(pdp->rgvarg+1) == -1)
1522c2c66affSColin Finck             ok(!*V_ARRAYREF(V_VARIANTREF(pdp->rgvarg)), "*V_ARRAYREF(V_VARIANTREF(pdp->rgvarg)) != NULL\n");
1523c2c66affSColin Finck         else
1524c2c66affSColin Finck             test_safearray(*V_ARRAYREF(V_VARIANTREF(pdp->rgvarg)), V_I2(pdp->rgvarg+1));
1525c2c66affSColin Finck         return S_OK;
1526c2c66affSColin Finck 
1527c2c66affSColin Finck     case DISPID_GLOBAL_THROWINT: {
1528c2c66affSColin Finck         VARIANT *v = pdp->rgvarg;
1529c2c66affSColin Finck         HRESULT hres;
1530c2c66affSColin Finck 
1531c2c66affSColin Finck         ok((wFlags & ~INVOKE_PROPERTYGET) == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1532c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1533c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1534c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1535c2c66affSColin Finck         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1536c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1537c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1538c2c66affSColin Finck         if(pvarRes) {
1539c2c66affSColin Finck             ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1540c2c66affSColin Finck             V_VT(pvarRes) = VT_BOOL;
1541c2c66affSColin Finck             V_BOOL(pvarRes) = VARIANT_FALSE;
1542c2c66affSColin Finck         }
1543c2c66affSColin Finck 
1544c2c66affSColin Finck         if(V_VT(v) == (VT_VARIANT|VT_BYREF))
1545c2c66affSColin Finck             v = V_VARIANTREF(v);
1546c2c66affSColin Finck 
1547c2c66affSColin Finck         switch(V_VT(v)) {
1548c2c66affSColin Finck         case VT_I2:
1549c2c66affSColin Finck             hres = V_I2(v);
1550c2c66affSColin Finck             break;
1551c2c66affSColin Finck         case VT_I4:
1552c2c66affSColin Finck             hres = V_I4(v);
1553c2c66affSColin Finck             break;
1554c2c66affSColin Finck         default:
1555c2c66affSColin Finck             ok(0, "unexpected vt %d\n", V_VT(v));
1556c2c66affSColin Finck             return E_INVALIDARG;
1557c2c66affSColin Finck         }
1558c2c66affSColin Finck 
1559c2c66affSColin Finck         return hres;
1560c2c66affSColin Finck     }
1561c2c66affSColin Finck 
1562c2c66affSColin Finck     case DISPID_GLOBAL_TESTOPTIONALARG: {
1563c2c66affSColin Finck         VARIANT *v;
1564c2c66affSColin Finck         int opt;
1565c2c66affSColin Finck 
1566c2c66affSColin Finck         CHECK_EXPECT(global_testoptionalarg_i);
1567c2c66affSColin Finck 
1568c2c66affSColin Finck         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1569c2c66affSColin Finck         ok(pdp != NULL, "pdp == NULL\n");
1570c2c66affSColin Finck         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1571c2c66affSColin Finck         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1572c2c66affSColin Finck         ok(pdp->cArgs == 3, "cArgs = %d\n", pdp->cArgs);
1573c2c66affSColin Finck         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1574c2c66affSColin Finck         ok(!pvarRes, "pvarRes != NULL\n");
1575c2c66affSColin Finck         ok(pei != NULL, "pei == NULL\n");
1576c2c66affSColin Finck 
1577c2c66affSColin Finck         ok(V_VT(pdp->rgvarg) == VT_I2, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1578c2c66affSColin Finck         opt = V_I2(pdp->rgvarg);
1579c2c66affSColin Finck         ok(opt == 1 || opt == 2, "opt = %d\n", opt);
1580c2c66affSColin Finck         v = pdp->rgvarg+pdp->cArgs-opt;
1581c2c66affSColin Finck         ok(V_VT(v) == VT_ERROR, "V_VT(v) = %d\n", V_VT(v));
1582c2c66affSColin Finck         ok(V_ERROR(v) == DISP_E_PARAMNOTFOUND, "V_ERROR(v) = %08x\n", V_ERROR(v));
1583c2c66affSColin Finck         return S_OK;
1584c2c66affSColin Finck     }
1585*7d76303dSAmine Khaldi     case DISPID_GLOBAL_GLOBALCALLBACK: {
1586*7d76303dSAmine Khaldi         DISPPARAMS dp = {0};
1587*7d76303dSAmine Khaldi         IDispatchEx *dispex;
1588*7d76303dSAmine Khaldi         EXCEPINFO ei;
1589*7d76303dSAmine Khaldi         VARIANT v;
1590*7d76303dSAmine Khaldi         DISPID id;
1591*7d76303dSAmine Khaldi         BSTR str;
1592*7d76303dSAmine Khaldi         HRESULT hres;
1593*7d76303dSAmine Khaldi 
1594*7d76303dSAmine Khaldi         CHECK_EXPECT(global_globalcallback_i);
1595*7d76303dSAmine Khaldi         CHECK_CALLED(OnEnterScript);
1596*7d76303dSAmine Khaldi 
1597*7d76303dSAmine Khaldi         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1598*7d76303dSAmine Khaldi         ok(pdp != NULL, "pdp == NULL\n");
1599*7d76303dSAmine Khaldi         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1600*7d76303dSAmine Khaldi         ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1601*7d76303dSAmine Khaldi         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1602*7d76303dSAmine Khaldi         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1603*7d76303dSAmine Khaldi         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1604*7d76303dSAmine Khaldi         ok(!pvarRes, "pvarRes != NULL\n");
1605*7d76303dSAmine Khaldi         ok(pei != NULL, "pei == NULL\n");
1606*7d76303dSAmine Khaldi 
1607*7d76303dSAmine Khaldi         hres = IDispatch_QueryInterface(V_DISPATCH(pdp->rgvarg), &IID_IDispatchEx, (void**)&dispex);
1608*7d76303dSAmine Khaldi         ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
1609*7d76303dSAmine Khaldi 
1610*7d76303dSAmine Khaldi         str = SysAllocString(L"callback");
1611*7d76303dSAmine Khaldi         hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id);
1612*7d76303dSAmine Khaldi         ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1613*7d76303dSAmine Khaldi         SysFreeString(str);
1614*7d76303dSAmine Khaldi 
1615*7d76303dSAmine Khaldi         SET_EXPECT(OnEnterScript);
1616*7d76303dSAmine Khaldi         SET_EXPECT(OnLeaveScript);
1617*7d76303dSAmine Khaldi         memset(&ei, 0, sizeof(ei));
1618*7d76303dSAmine Khaldi         hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_METHOD, &dp, &v, &ei, pspCaller);
1619*7d76303dSAmine Khaldi         ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1620*7d76303dSAmine Khaldi         CHECK_CALLED(OnEnterScript);
1621*7d76303dSAmine Khaldi         CHECK_CALLED(OnLeaveScript);
1622*7d76303dSAmine Khaldi         ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
1623*7d76303dSAmine Khaldi         ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
1624*7d76303dSAmine Khaldi 
1625*7d76303dSAmine Khaldi         IDispatchEx_Release(dispex);
1626*7d76303dSAmine Khaldi 
1627*7d76303dSAmine Khaldi         SET_EXPECT(OnLeaveScript);
1628*7d76303dSAmine Khaldi         return S_OK;
1629*7d76303dSAmine Khaldi     }
1630*7d76303dSAmine Khaldi     case DISPID_GLOBAL_TESTERROROBJECT: {
1631*7d76303dSAmine Khaldi         ITypeInfo *typeinfo;
1632*7d76303dSAmine Khaldi         IDispatchEx *dispex;
1633*7d76303dSAmine Khaldi         DISPPARAMS dp;
1634*7d76303dSAmine Khaldi         VARIANT v, r;
1635*7d76303dSAmine Khaldi         EXCEPINFO ei;
1636*7d76303dSAmine Khaldi         IDispatch *disp;
1637*7d76303dSAmine Khaldi         WCHAR *names[1];
1638*7d76303dSAmine Khaldi         UINT count, i;
1639*7d76303dSAmine Khaldi         DISPID id;
1640*7d76303dSAmine Khaldi         HRESULT hres;
1641*7d76303dSAmine Khaldi 
1642*7d76303dSAmine Khaldi         static WCHAR props[][32] = { L"clear", L"description", L"helpcontext", L"helpFILE", L"number", L"raise", L"source" };
1643*7d76303dSAmine Khaldi 
1644*7d76303dSAmine Khaldi         CHECK_EXPECT(global_testerrorobject_i);
1645*7d76303dSAmine Khaldi 
1646*7d76303dSAmine Khaldi         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1647*7d76303dSAmine Khaldi         ok(pdp != NULL, "pdp == NULL\n");
1648*7d76303dSAmine Khaldi         ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1649*7d76303dSAmine Khaldi         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1650*7d76303dSAmine Khaldi         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1651*7d76303dSAmine Khaldi         ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1652*7d76303dSAmine Khaldi         ok(!pvarRes, "pvarRes != NULL\n");
1653*7d76303dSAmine Khaldi         ok(pei != NULL, "pei == NULL\n");
1654*7d76303dSAmine Khaldi 
1655*7d76303dSAmine Khaldi         ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1656*7d76303dSAmine Khaldi         disp = V_DISPATCH(pdp->rgvarg);
1657*7d76303dSAmine Khaldi         hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
1658*7d76303dSAmine Khaldi         ok(hres == E_NOINTERFACE, "Could not get IDispatchEx iface: %08x\n", hres);
1659*7d76303dSAmine Khaldi 
1660*7d76303dSAmine Khaldi         hres = IDispatch_GetTypeInfoCount(disp, &count);
1661*7d76303dSAmine Khaldi         ok(hres == S_OK, "GetTypeInfoCount returned: %08x\n", hres);
1662*7d76303dSAmine Khaldi         ok(count == 0, "count = %u\n", count);
1663*7d76303dSAmine Khaldi 
1664*7d76303dSAmine Khaldi         hres = IDispatch_GetTypeInfo(disp, 0, 0, &typeinfo);
1665*7d76303dSAmine Khaldi         ok(hres == DISP_E_BADINDEX, "GetTypeInfo returned: %08x\n", hres);
1666*7d76303dSAmine Khaldi 
1667*7d76303dSAmine Khaldi         for(i = 0; i < ARRAY_SIZE(props); i++) {
1668*7d76303dSAmine Khaldi             names[0] = props[i];
1669*7d76303dSAmine Khaldi             hres = IDispatch_GetIDsOfNames(disp, &IID_NULL, names, 1, 0, &id);
1670*7d76303dSAmine Khaldi             ok(hres == S_OK, "GetIDsOfNames failed: %08x\n", hres);
1671*7d76303dSAmine Khaldi             ok(id == i + 1, "%s id = %u\n", wine_dbgstr_w(props[i]), id);
1672*7d76303dSAmine Khaldi         }
1673*7d76303dSAmine Khaldi 
1674*7d76303dSAmine Khaldi         memset(&dp, 0, sizeof(dp));
1675*7d76303dSAmine Khaldi         memset(&ei, 0, sizeof(ei));
1676*7d76303dSAmine Khaldi         V_VT(&v) = VT_ERROR;
1677*7d76303dSAmine Khaldi         hres = IDispatch_Invoke(disp, 5, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
1678*7d76303dSAmine Khaldi         ok(hres == S_OK, "Invoke failed: %08x\n", hres);
1679*7d76303dSAmine Khaldi         ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
1680*7d76303dSAmine Khaldi         ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
1681*7d76303dSAmine Khaldi         hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
1682*7d76303dSAmine Khaldi         ok(hres == S_OK, "Invoke failed: %08x\n", hres);
1683*7d76303dSAmine Khaldi         ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
1684*7d76303dSAmine Khaldi         ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
1685*7d76303dSAmine Khaldi 
1686*7d76303dSAmine Khaldi         dp.rgvarg = &v;
1687*7d76303dSAmine Khaldi         V_VT(&v) = VT_I4;
1688*7d76303dSAmine Khaldi         V_I4(&v) = 6;
1689*7d76303dSAmine Khaldi         V_VT(&r) = VT_EMPTY;
1690*7d76303dSAmine Khaldi         hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 6, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dp, &r, &ei, NULL);
1691*7d76303dSAmine Khaldi         ok(hres == S_OK, "Invoke failed: %08x\n", hres);
1692*7d76303dSAmine Khaldi         return S_OK;
1693*7d76303dSAmine Khaldi     }
1694c2c66affSColin Finck     }
1695c2c66affSColin Finck 
1696c2c66affSColin Finck     ok(0, "unexpected call %d\n", id);
1697c2c66affSColin Finck     return DISP_E_MEMBERNOTFOUND;
1698c2c66affSColin Finck }
1699c2c66affSColin Finck 
1700c2c66affSColin Finck static IDispatchExVtbl GlobalVtbl = {
1701c2c66affSColin Finck     DispatchEx_QueryInterface,
1702c78e8736SAmine Khaldi     Global_AddRef,
1703c78e8736SAmine Khaldi     Global_Release,
1704c2c66affSColin Finck     DispatchEx_GetTypeInfoCount,
1705c2c66affSColin Finck     DispatchEx_GetTypeInfo,
1706c2c66affSColin Finck     DispatchEx_GetIDsOfNames,
1707c2c66affSColin Finck     DispatchEx_Invoke,
1708c2c66affSColin Finck     Global_GetDispID,
1709c2c66affSColin Finck     Global_InvokeEx,
1710c2c66affSColin Finck     DispatchEx_DeleteMemberByName,
1711c2c66affSColin Finck     DispatchEx_DeleteMemberByDispID,
1712c2c66affSColin Finck     DispatchEx_GetMemberProperties,
1713c2c66affSColin Finck     DispatchEx_GetMemberName,
1714c2c66affSColin Finck     DispatchEx_GetNextDispID,
1715c2c66affSColin Finck     DispatchEx_GetNameSpaceParent
1716c2c66affSColin Finck };
1717c2c66affSColin Finck 
1718c2c66affSColin Finck static IDispatchEx Global = { &GlobalVtbl };
1719c2c66affSColin Finck 
ActiveScriptSiteWindow_QueryInterface(IActiveScriptSiteWindow * iface,REFIID riid,void ** ppv)1720c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSiteWindow_QueryInterface(IActiveScriptSiteWindow *iface, REFIID riid, void **ppv)
1721c2c66affSColin Finck {
1722c2c66affSColin Finck     ok(0, "unexpected call\n");
1723c2c66affSColin Finck     return E_NOINTERFACE;
1724c2c66affSColin Finck }
1725c2c66affSColin Finck 
ActiveScriptSiteWindow_AddRef(IActiveScriptSiteWindow * iface)1726c2c66affSColin Finck static ULONG WINAPI ActiveScriptSiteWindow_AddRef(IActiveScriptSiteWindow *iface)
1727c2c66affSColin Finck {
1728c2c66affSColin Finck     return 2;
1729c2c66affSColin Finck }
1730c2c66affSColin Finck 
ActiveScriptSiteWindow_Release(IActiveScriptSiteWindow * iface)1731c2c66affSColin Finck static ULONG WINAPI ActiveScriptSiteWindow_Release(IActiveScriptSiteWindow *iface)
1732c2c66affSColin Finck {
1733c2c66affSColin Finck     return 1;
1734c2c66affSColin Finck }
1735c2c66affSColin Finck 
ActiveScriptSiteWindow_GetWindow(IActiveScriptSiteWindow * iface,HWND * phwnd)1736c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSiteWindow_GetWindow(IActiveScriptSiteWindow *iface, HWND *phwnd)
1737c2c66affSColin Finck {
1738c2c66affSColin Finck     if(!allow_ui)
1739c2c66affSColin Finck         CHECK_EXPECT(GetWindow);
1740c2c66affSColin Finck     *phwnd = NULL;
1741c2c66affSColin Finck     return S_OK;
1742c2c66affSColin Finck }
1743c2c66affSColin Finck 
ActiveScriptSiteWindow_EnableModeless(IActiveScriptSiteWindow * iface,BOOL fEnable)1744c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSiteWindow_EnableModeless(IActiveScriptSiteWindow *iface, BOOL fEnable)
1745c2c66affSColin Finck {
1746c2c66affSColin Finck     if(allow_ui)
1747c2c66affSColin Finck         return S_OK;
1748c2c66affSColin Finck 
1749c2c66affSColin Finck     CHECK_EXPECT(EnableModeless);
1750c2c66affSColin Finck     ok(!fEnable, "fEnable = %x\n", fEnable);
1751c2c66affSColin Finck     return E_FAIL;
1752c2c66affSColin Finck }
1753c2c66affSColin Finck 
1754c2c66affSColin Finck static const IActiveScriptSiteWindowVtbl ActiveScriptSiteWindowVtbl = {
1755c2c66affSColin Finck     ActiveScriptSiteWindow_QueryInterface,
1756c2c66affSColin Finck     ActiveScriptSiteWindow_AddRef,
1757c2c66affSColin Finck     ActiveScriptSiteWindow_Release,
1758c2c66affSColin Finck     ActiveScriptSiteWindow_GetWindow,
1759c2c66affSColin Finck     ActiveScriptSiteWindow_EnableModeless
1760c2c66affSColin Finck };
1761c2c66affSColin Finck 
1762c2c66affSColin Finck static IActiveScriptSiteWindow ActiveScriptSiteWindow = { &ActiveScriptSiteWindowVtbl };
1763c2c66affSColin Finck 
ActiveScriptSiteUIControl_QueryInterface(IActiveScriptSiteUIControl * iface,REFIID riid,void ** ppv)1764c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSiteUIControl_QueryInterface(IActiveScriptSiteUIControl *iface, REFIID riid, void **ppv)
1765c2c66affSColin Finck {
1766c2c66affSColin Finck     ok(0, "unexpected call\n");
1767c2c66affSColin Finck     return E_NOINTERFACE;
1768c2c66affSColin Finck }
1769c2c66affSColin Finck 
ActiveScriptSiteUIControl_AddRef(IActiveScriptSiteUIControl * iface)1770c2c66affSColin Finck static ULONG WINAPI ActiveScriptSiteUIControl_AddRef(IActiveScriptSiteUIControl *iface)
1771c2c66affSColin Finck {
1772c2c66affSColin Finck     return 2;
1773c2c66affSColin Finck }
1774c2c66affSColin Finck 
ActiveScriptSiteUIControl_Release(IActiveScriptSiteUIControl * iface)1775c2c66affSColin Finck static ULONG WINAPI ActiveScriptSiteUIControl_Release(IActiveScriptSiteUIControl *iface)
1776c2c66affSColin Finck {
1777c2c66affSColin Finck     return 1;
1778c2c66affSColin Finck }
1779c2c66affSColin Finck 
ActiveScriptSiteUIControl_GetUIBehavior(IActiveScriptSiteUIControl * iface,SCRIPTUICITEM UicItem,SCRIPTUICHANDLING * pUicHandling)1780c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSiteUIControl_GetUIBehavior(IActiveScriptSiteUIControl *iface, SCRIPTUICITEM UicItem,
1781c2c66affSColin Finck         SCRIPTUICHANDLING *pUicHandling)
1782c2c66affSColin Finck {
1783c2c66affSColin Finck     if(!allow_ui) {
1784c2c66affSColin Finck         CHECK_EXPECT(GetUIBehavior);
1785c2c66affSColin Finck         ok(UicItem == SCRIPTUICITEM_MSGBOX, "UidItem = %d\n", UicItem);
1786c2c66affSColin Finck     }
1787c2c66affSColin Finck     *pUicHandling = uic_handling;
1788c2c66affSColin Finck     return S_OK;
1789c2c66affSColin Finck }
1790c2c66affSColin Finck 
1791c2c66affSColin Finck static const IActiveScriptSiteUIControlVtbl ActiveScriptSiteUIControlVtbl = {
1792c2c66affSColin Finck     ActiveScriptSiteUIControl_QueryInterface,
1793c2c66affSColin Finck     ActiveScriptSiteUIControl_AddRef,
1794c2c66affSColin Finck     ActiveScriptSiteUIControl_Release,
1795c2c66affSColin Finck     ActiveScriptSiteUIControl_GetUIBehavior
1796c2c66affSColin Finck };
1797c2c66affSColin Finck 
1798c2c66affSColin Finck static IActiveScriptSiteUIControl ActiveScriptSiteUIControl = { &ActiveScriptSiteUIControlVtbl };
1799c2c66affSColin Finck 
ActiveScriptSite_QueryInterface(IActiveScriptSite * iface,REFIID riid,void ** ppv)1800c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
1801c2c66affSColin Finck {
1802c2c66affSColin Finck     *ppv = NULL;
1803c2c66affSColin Finck 
1804c2c66affSColin Finck     if(IsEqualGUID(&IID_IUnknown, riid))
1805c2c66affSColin Finck         *ppv = iface;
1806c2c66affSColin Finck     else if(IsEqualGUID(&IID_IActiveScriptSite, riid))
1807c2c66affSColin Finck         *ppv = iface;
1808c2c66affSColin Finck     else if(IsEqualGUID(&IID_IActiveScriptSiteWindow, riid))
1809c2c66affSColin Finck         *ppv = &ActiveScriptSiteWindow;
1810c2c66affSColin Finck     else if(IsEqualGUID(&IID_IActiveScriptSiteUIControl, riid))
1811c2c66affSColin Finck         *ppv = &ActiveScriptSiteUIControl;
1812c2c66affSColin Finck     else
1813c2c66affSColin Finck         return E_NOINTERFACE;
1814c2c66affSColin Finck 
1815c2c66affSColin Finck     IUnknown_AddRef((IUnknown*)*ppv);
1816c2c66affSColin Finck     return S_OK;
1817c2c66affSColin Finck }
1818c2c66affSColin Finck 
ActiveScriptSite_AddRef(IActiveScriptSite * iface)1819c2c66affSColin Finck static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
1820c2c66affSColin Finck {
1821c2c66affSColin Finck     return 2;
1822c2c66affSColin Finck }
1823c2c66affSColin Finck 
ActiveScriptSite_Release(IActiveScriptSite * iface)1824c2c66affSColin Finck static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
1825c2c66affSColin Finck {
1826c2c66affSColin Finck     return 1;
1827c2c66affSColin Finck }
1828c2c66affSColin Finck 
ActiveScriptSite_GetLCID(IActiveScriptSite * iface,LCID * plcid)1829c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
1830c2c66affSColin Finck {
1831c2c66affSColin Finck     *plcid = GetUserDefaultLCID();
1832c2c66affSColin Finck     return S_OK;
1833c2c66affSColin Finck }
1834c2c66affSColin Finck 
ActiveScriptSite_GetItemInfo(IActiveScriptSite * iface,LPCOLESTR pstrName,DWORD dwReturnMask,IUnknown ** ppiunkItem,ITypeInfo ** ppti)1835c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName,
1836c2c66affSColin Finck         DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
1837c2c66affSColin Finck {
1838c2c66affSColin Finck     ok(dwReturnMask == SCRIPTINFO_IUNKNOWN, "unexpected dwReturnMask %x\n", dwReturnMask);
1839c2c66affSColin Finck     ok(!ppti, "ppti != NULL\n");
1840c2c66affSColin Finck 
1841c2c66affSColin Finck     if(strcmp_wa(pstrName, "test"))
1842c2c66affSColin Finck         ok(0, "unexpected pstrName %s\n", wine_dbgstr_w(pstrName));
1843c2c66affSColin Finck 
1844c2c66affSColin Finck     *ppiunkItem = (IUnknown*)&Global;
1845c78e8736SAmine Khaldi     IUnknown_AddRef(*ppiunkItem);
1846c2c66affSColin Finck     return S_OK;
1847c2c66affSColin Finck }
1848c2c66affSColin Finck 
ActiveScriptSite_GetDocVersionString(IActiveScriptSite * iface,BSTR * pbstrVersion)1849c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
1850c2c66affSColin Finck {
1851c2c66affSColin Finck     return E_NOTIMPL;
1852c2c66affSColin Finck }
1853c2c66affSColin Finck 
ActiveScriptSite_OnScriptTerminate(IActiveScriptSite * iface,const VARIANT * pvarResult,const EXCEPINFO * pexcepinfo)1854c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface,
1855c2c66affSColin Finck         const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
1856c2c66affSColin Finck {
1857c2c66affSColin Finck     return E_NOTIMPL;
1858c2c66affSColin Finck }
1859c2c66affSColin Finck 
ActiveScriptSite_OnStateChange(IActiveScriptSite * iface,SCRIPTSTATE ssScriptState)1860c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
1861c2c66affSColin Finck {
1862c2c66affSColin Finck     return E_NOTIMPL;
1863c2c66affSColin Finck }
1864c2c66affSColin Finck 
1865*7d76303dSAmine Khaldi static IActiveScriptError **store_script_error;
1866*7d76303dSAmine Khaldi 
ActiveScriptSite_OnScriptError(IActiveScriptSite * iface,IActiveScriptError * pscripterror)1867c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
1868c2c66affSColin Finck {
1869*7d76303dSAmine Khaldi     HRESULT hr = onerror_hres, hres;
1870c2c66affSColin Finck 
1871942c4265SAmine Khaldi     if(!expect_OnScriptError) {
1872942c4265SAmine Khaldi         EXCEPINFO info;
1873942c4265SAmine Khaldi         ULONG line;
1874942c4265SAmine Khaldi         HRESULT hres;
1875942c4265SAmine Khaldi 
1876942c4265SAmine Khaldi         hres = IActiveScriptError_GetSourcePosition(pscripterror, NULL, &line, NULL);
1877942c4265SAmine Khaldi         if(SUCCEEDED(hres))
1878942c4265SAmine Khaldi             hres = IActiveScriptError_GetExceptionInfo(pscripterror, &info);
1879942c4265SAmine Khaldi         if(SUCCEEDED(hres))
1880*7d76303dSAmine Khaldi             trace("Error in line %u: %x %s\n", line+1, info.wCode, wine_dbgstr_w(info.bstrDescription));
1881*7d76303dSAmine Khaldi     }else {
1882*7d76303dSAmine Khaldi         IDispatchEx *dispex;
1883*7d76303dSAmine Khaldi 
1884*7d76303dSAmine Khaldi         hres = IActiveScriptError_QueryInterface(pscripterror, &IID_IDispatchEx, (void**)&dispex);
1885*7d76303dSAmine Khaldi         ok(hres == E_NOINTERFACE, "QI(IDispatchEx) returned: %08x\n", hres);
1886*7d76303dSAmine Khaldi     }
1887*7d76303dSAmine Khaldi 
1888*7d76303dSAmine Khaldi     if(store_script_error) {
1889*7d76303dSAmine Khaldi         IActiveScriptError_AddRef(pscripterror);
1890*7d76303dSAmine Khaldi         *store_script_error = pscripterror;
1891*7d76303dSAmine Khaldi         store_script_error = NULL;
1892942c4265SAmine Khaldi     }
1893942c4265SAmine Khaldi 
1894942c4265SAmine Khaldi     CHECK_EXPECT(OnScriptError);
1895c2c66affSColin Finck     onerror_hres = E_NOTIMPL;
1896c2c66affSColin Finck 
1897c2c66affSColin Finck     return hr;
1898c2c66affSColin Finck }
1899c2c66affSColin Finck 
ActiveScriptSite_OnEnterScript(IActiveScriptSite * iface)1900c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
1901c2c66affSColin Finck {
1902*7d76303dSAmine Khaldi     if(strict_enter_script)
1903*7d76303dSAmine Khaldi         CHECK_EXPECT(OnEnterScript);
1904c2c66affSColin Finck     return E_NOTIMPL;
1905c2c66affSColin Finck }
1906c2c66affSColin Finck 
ActiveScriptSite_OnLeaveScript(IActiveScriptSite * iface)1907c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
1908c2c66affSColin Finck {
1909*7d76303dSAmine Khaldi     if(strict_enter_script)
1910*7d76303dSAmine Khaldi         CHECK_EXPECT(OnLeaveScript);
1911c2c66affSColin Finck     return E_NOTIMPL;
1912c2c66affSColin Finck }
1913c2c66affSColin Finck 
1914c2c66affSColin Finck static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
1915c2c66affSColin Finck     ActiveScriptSite_QueryInterface,
1916c2c66affSColin Finck     ActiveScriptSite_AddRef,
1917c2c66affSColin Finck     ActiveScriptSite_Release,
1918c2c66affSColin Finck     ActiveScriptSite_GetLCID,
1919c2c66affSColin Finck     ActiveScriptSite_GetItemInfo,
1920c2c66affSColin Finck     ActiveScriptSite_GetDocVersionString,
1921c2c66affSColin Finck     ActiveScriptSite_OnScriptTerminate,
1922c2c66affSColin Finck     ActiveScriptSite_OnStateChange,
1923c2c66affSColin Finck     ActiveScriptSite_OnScriptError,
1924c2c66affSColin Finck     ActiveScriptSite_OnEnterScript,
1925c2c66affSColin Finck     ActiveScriptSite_OnLeaveScript
1926c2c66affSColin Finck };
1927c2c66affSColin Finck 
1928c2c66affSColin Finck static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
1929c2c66affSColin Finck 
create_script(void)1930c2c66affSColin Finck static IActiveScript *create_script(void)
1931c2c66affSColin Finck {
1932c2c66affSColin Finck     IActiveScript *script;
1933c2c66affSColin Finck     HRESULT hres;
1934c2c66affSColin Finck 
1935c2c66affSColin Finck     hres = CoCreateInstance(&CLSID_VBScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1936c2c66affSColin Finck             &IID_IActiveScript, (void**)&script);
1937c2c66affSColin Finck     ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
1938c2c66affSColin Finck 
1939c2c66affSColin Finck     return script;
1940c2c66affSColin Finck }
1941c2c66affSColin Finck 
create_and_init_script(DWORD flags,BOOL start)1942*7d76303dSAmine Khaldi static IActiveScript *create_and_init_script(DWORD flags, BOOL start)
1943c2c66affSColin Finck {
1944c2c66affSColin Finck     IActiveScriptParse *parser;
1945c2c66affSColin Finck     IActiveScript *engine;
1946c2c66affSColin Finck     HRESULT hres;
1947c2c66affSColin Finck 
1948c2c66affSColin Finck     engine = create_script();
1949c2c66affSColin Finck     if(!engine)
1950c2c66affSColin Finck         return NULL;
1951c2c66affSColin Finck 
1952c2c66affSColin Finck     hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
1953c2c66affSColin Finck     ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
1954c2c66affSColin Finck 
1955c2c66affSColin Finck     hres = IActiveScriptParse_InitNew(parser);
1956c2c66affSColin Finck     ok(hres == S_OK, "InitNew failed: %08x\n", hres);
1957c2c66affSColin Finck 
1958c2c66affSColin Finck     IActiveScriptParse_Release(parser);
1959c2c66affSColin Finck 
1960c2c66affSColin Finck     hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
1961c2c66affSColin Finck     ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
1962c2c66affSColin Finck 
1963c2c66affSColin Finck     hres = IActiveScript_AddNamedItem(engine, testW,
1964c2c66affSColin Finck             SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|flags);
1965c2c66affSColin Finck     ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
1966c2c66affSColin Finck 
1967*7d76303dSAmine Khaldi     if (start)
1968*7d76303dSAmine Khaldi     {
1969c2c66affSColin Finck         hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
1970c2c66affSColin Finck         ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
1971*7d76303dSAmine Khaldi     }
1972c2c66affSColin Finck 
1973c2c66affSColin Finck     return engine;
1974c2c66affSColin Finck }
1975c2c66affSColin Finck 
close_script(IActiveScript * script)1976c2c66affSColin Finck static void close_script(IActiveScript *script)
1977c2c66affSColin Finck {
1978c2c66affSColin Finck     ULONG ref;
1979c2c66affSColin Finck     HRESULT hres;
1980c2c66affSColin Finck 
1981c2c66affSColin Finck     hres = IActiveScript_Close(script);
1982c2c66affSColin Finck     ok(hres == S_OK, "Close failed: %08x\n", hres);
1983c2c66affSColin Finck 
1984c2c66affSColin Finck     ref = IActiveScript_Release(script);
1985c2c66affSColin Finck     ok(!ref, "ref=%u\n", ref);
1986c2c66affSColin Finck }
1987c2c66affSColin Finck 
parse_script(DWORD flags,BSTR script_str,const WCHAR * delim)1988c2c66affSColin Finck static HRESULT parse_script(DWORD flags, BSTR script_str, const WCHAR *delim)
1989c2c66affSColin Finck {
1990c2c66affSColin Finck     IActiveScriptParse *parser;
1991c2c66affSColin Finck     IActiveScript *engine;
1992c2c66affSColin Finck     IDispatch *script_disp;
1993c2c66affSColin Finck     LONG ref;
1994c2c66affSColin Finck     HRESULT hres;
1995c2c66affSColin Finck 
1996*7d76303dSAmine Khaldi     engine = create_and_init_script(flags, TRUE);
1997c2c66affSColin Finck     if(!engine)
1998c2c66affSColin Finck         return S_OK;
1999c2c66affSColin Finck 
2000c2c66affSColin Finck     hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2001c2c66affSColin Finck     ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2002c2c66affSColin Finck     if (FAILED(hres))
2003c2c66affSColin Finck     {
2004c2c66affSColin Finck         IActiveScript_Release(engine);
2005c2c66affSColin Finck         return hres;
2006c2c66affSColin Finck     }
2007c2c66affSColin Finck 
2008c2c66affSColin Finck     hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
2009c2c66affSColin Finck     ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
2010c2c66affSColin Finck     ok(script_disp != NULL, "script_disp == NULL\n");
2011c2c66affSColin Finck     ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n");
2012c2c66affSColin Finck 
2013c2c66affSColin Finck     test_counter = 0;
2014c2c66affSColin Finck 
2015c2c66affSColin Finck     hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, delim, 0, 0, 0, NULL, NULL);
2016c2c66affSColin Finck 
2017c2c66affSColin Finck     IActiveScript_Close(engine);
2018c2c66affSColin Finck 
2019c2c66affSColin Finck     IDispatch_Release(script_disp);
2020c2c66affSColin Finck     IActiveScript_Release(engine);
2021c2c66affSColin Finck 
2022c2c66affSColin Finck     ref = IActiveScriptParse_Release(parser);
2023c2c66affSColin Finck     ok(!ref, "ref=%d\n", ref);
2024c2c66affSColin Finck     return hres;
2025c2c66affSColin Finck }
2026c2c66affSColin Finck 
parse_script_af(DWORD flags,const char * src)2027c2c66affSColin Finck static void parse_script_af(DWORD flags, const char *src)
2028c2c66affSColin Finck {
2029c2c66affSColin Finck     BSTR tmp;
2030c2c66affSColin Finck     HRESULT hres;
2031c2c66affSColin Finck 
2032c2c66affSColin Finck     tmp = a2bstr(src);
2033c2c66affSColin Finck     hres = parse_script(flags, tmp, NULL);
2034c2c66affSColin Finck     SysFreeString(tmp);
2035c2c66affSColin Finck     ok(hres == S_OK, "parse_script failed: %08x\n", hres);
2036c2c66affSColin Finck }
2037c2c66affSColin Finck 
parse_script_ar(const char * src)2038c2c66affSColin Finck static HRESULT parse_script_ar(const char *src)
2039c2c66affSColin Finck {
2040c2c66affSColin Finck     BSTR tmp;
2041c2c66affSColin Finck     HRESULT hres;
2042c2c66affSColin Finck 
2043c2c66affSColin Finck     tmp = a2bstr(src);
2044c2c66affSColin Finck     hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, tmp, NULL);
2045c2c66affSColin Finck     SysFreeString(tmp);
2046c2c66affSColin Finck     return hres;
2047c2c66affSColin Finck }
2048c2c66affSColin Finck 
test_parse_context(void)2049c78e8736SAmine Khaldi static void test_parse_context(void)
2050c78e8736SAmine Khaldi {
2051c78e8736SAmine Khaldi     IActiveScriptParse *parser;
2052c78e8736SAmine Khaldi     IActiveScript *engine;
2053c78e8736SAmine Khaldi     BSTR str;
2054c78e8736SAmine Khaldi     HRESULT hres;
2055c78e8736SAmine Khaldi 
2056c78e8736SAmine Khaldi     static const WCHAR xW[] = {'x',0};
2057c78e8736SAmine Khaldi     static const WCHAR yW[] = {'y',0};
2058c78e8736SAmine Khaldi 
2059c78e8736SAmine Khaldi     global_ref = 1;
2060*7d76303dSAmine Khaldi     engine = create_and_init_script(0, TRUE);
2061c78e8736SAmine Khaldi     if(!engine)
2062c78e8736SAmine Khaldi         return;
2063c78e8736SAmine Khaldi 
2064c78e8736SAmine Khaldi     hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2065c78e8736SAmine Khaldi     ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2066c78e8736SAmine Khaldi 
2067*7d76303dSAmine Khaldi     /* NULL code text succeeds but does nothing */
2068*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2069*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2070*7d76303dSAmine Khaldi 
2071c78e8736SAmine Khaldi     /* unknown identifier context is not a valid argument */
2072c78e8736SAmine Khaldi     str = a2bstr("Call reportSuccess()\n");
2073c78e8736SAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, yW, NULL, NULL, 0, 0, 0, NULL, NULL);
2074c78e8736SAmine Khaldi     ok(hres == E_INVALIDARG, "ParseScriptText failed: %08x\n", hres);
2075c78e8736SAmine Khaldi     SysFreeString(str);
2076c78e8736SAmine Khaldi 
2077c78e8736SAmine Khaldi     str = a2bstr("class Cl\n"
2078c78e8736SAmine Khaldi                  "    Public Sub ClMethod\n"
2079c78e8736SAmine Khaldi                  "        Call reportSuccess()\n"
2080c78e8736SAmine Khaldi                  "    End Sub\n"
2081c78e8736SAmine Khaldi                  "End Class\n"
2082c78e8736SAmine Khaldi                  "Dim x\n"
2083c78e8736SAmine Khaldi                  "set x = new Cl\n");
2084c78e8736SAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2085c78e8736SAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2086c78e8736SAmine Khaldi     SysFreeString(str);
2087c78e8736SAmine Khaldi 
2088c78e8736SAmine Khaldi     /* known global variable is not a valid context */
2089c78e8736SAmine Khaldi     str = a2bstr("Call reportSuccess()\n");
2090c78e8736SAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, xW, NULL, NULL, 0, 0, 0, NULL, NULL);
2091c78e8736SAmine Khaldi     ok(hres == E_INVALIDARG, "ParseScriptText failed: %08x\n", hres);
2092c78e8736SAmine Khaldi     SysFreeString(str);
2093c78e8736SAmine Khaldi 
2094c78e8736SAmine Khaldi     SET_EXPECT(global_success_d);
2095c78e8736SAmine Khaldi     SET_EXPECT(global_success_i);
2096c78e8736SAmine Khaldi     str = a2bstr("Call reportSuccess()\n");
2097c78e8736SAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, testW, NULL, NULL, 0, 0, 0, NULL, NULL);
2098c78e8736SAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2099c78e8736SAmine Khaldi     SysFreeString(str);
2100c78e8736SAmine Khaldi     CHECK_CALLED(global_success_d);
2101c78e8736SAmine Khaldi     CHECK_CALLED(global_success_i);
2102c78e8736SAmine Khaldi 
2103c78e8736SAmine Khaldi     IActiveScriptParse_Release(parser);
2104c78e8736SAmine Khaldi     close_script(engine);
2105c78e8736SAmine Khaldi     ok(global_ref == 1, "global_ref = %u\n", global_ref);
2106c78e8736SAmine Khaldi }
2107c78e8736SAmine Khaldi 
parse_script_a(const char * src)2108c2c66affSColin Finck static void parse_script_a(const char *src)
2109c2c66affSColin Finck {
2110c2c66affSColin Finck     parse_script_af(SCRIPTITEM_GLOBALMEMBERS, src);
2111c2c66affSColin Finck }
2112c2c66affSColin Finck 
2113c2c66affSColin Finck #define parse_htmlscript_a(a) _parse_htmlscript_a(__LINE__,a)
_parse_htmlscript_a(unsigned line,const char * src)2114c2c66affSColin Finck static void _parse_htmlscript_a(unsigned line, const char *src)
2115c2c66affSColin Finck {
2116c2c66affSColin Finck     BSTR tmp;
2117c2c66affSColin Finck     HRESULT hres;
2118c2c66affSColin Finck 
2119c2c66affSColin Finck     static const WCHAR script_delimW[] = {'<','/','S','C','R','I','P','T','>',0};
2120c2c66affSColin Finck 
2121c2c66affSColin Finck     tmp = a2bstr(src);
2122c2c66affSColin Finck     hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, tmp, script_delimW);
2123c2c66affSColin Finck     SysFreeString(tmp);
2124c2c66affSColin Finck     ok_(__FILE__,line)(hres == S_OK, "parse_script failed: %08x\n", hres);
2125c2c66affSColin Finck }
2126c2c66affSColin Finck 
parse_procedure(IActiveScriptParseProcedure2 * parse_proc,const char * src,DWORD flags)2127*7d76303dSAmine Khaldi static IDispatchEx *parse_procedure(IActiveScriptParseProcedure2 *parse_proc, const char *src, DWORD flags)
2128c2c66affSColin Finck {
2129c2c66affSColin Finck     IDispatchEx *dispex;
2130c2c66affSColin Finck     IDispatch *disp;
2131c2c66affSColin Finck     BSTR str;
2132c2c66affSColin Finck     HRESULT hres;
2133c2c66affSColin Finck 
2134c2c66affSColin Finck     static const WCHAR delimiterW[] = {'\"',0};
2135c2c66affSColin Finck 
2136c2c66affSColin Finck     str = a2bstr(src);
2137c2c66affSColin Finck     hres = IActiveScriptParseProcedure2_ParseProcedureText(parse_proc, str, NULL, emptyW, NULL, NULL, delimiterW, 0, 0,
2138*7d76303dSAmine Khaldi             SCRIPTPROC_HOSTMANAGESSOURCE|SCRIPTPROC_IMPLICIT_THIS|SCRIPTPROC_IMPLICIT_PARENTS|flags, &disp);
2139c2c66affSColin Finck     SysFreeString(str);
2140c2c66affSColin Finck     ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres);
2141c2c66affSColin Finck     ok(disp != NULL, "disp = NULL\n");
2142c2c66affSColin Finck 
2143c2c66affSColin Finck     hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
2144c2c66affSColin Finck     IDispatch_Release(disp);
2145c2c66affSColin Finck     ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
2146c2c66affSColin Finck 
2147c2c66affSColin Finck     return dispex;
2148c2c66affSColin Finck }
2149c2c66affSColin Finck 
2150c2c66affSColin Finck 
test_procedures(void)2151c2c66affSColin Finck static void test_procedures(void)
2152c2c66affSColin Finck {
2153c2c66affSColin Finck     IActiveScriptParseProcedure2 *parse_proc;
2154c2c66affSColin Finck     DISPPARAMS dp = {NULL};
2155c2c66affSColin Finck     IActiveScript *script;
2156c2c66affSColin Finck     IDispatchEx *proc;
2157*7d76303dSAmine Khaldi     IDispatch *disp;
2158c2c66affSColin Finck     EXCEPINFO ei = {0};
2159c2c66affSColin Finck     VARIANT v;
2160c2c66affSColin Finck     HRESULT hres;
2161c2c66affSColin Finck 
2162*7d76303dSAmine Khaldi     strict_enter_script = TRUE;
2163*7d76303dSAmine Khaldi     script = create_and_init_script(0, TRUE);
2164c2c66affSColin Finck 
2165c2c66affSColin Finck     hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
2166c2c66affSColin Finck     ok(hres == S_OK, "Could not get IActiveScriptParseProcedure2 iface: %08x\n", hres);
2167c2c66affSColin Finck 
2168*7d76303dSAmine Khaldi     hres = IActiveScriptParseProcedure2_ParseProcedureText(parse_proc, NULL, NULL, emptyW, NULL, NULL, NULL, 0, 0, 0, &disp);
2169*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres);
2170*7d76303dSAmine Khaldi     IDispatch_Release(disp);
2171c2c66affSColin Finck 
2172*7d76303dSAmine Khaldi     proc = parse_procedure(parse_proc, "dim x\nif true then x=false", 0);
2173*7d76303dSAmine Khaldi 
2174*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2175*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2176c2c66affSColin Finck     V_VT(&v) = VT_EMPTY;
2177c2c66affSColin Finck     hres = IDispatchEx_InvokeEx(proc, DISPID_VALUE, 0, DISPATCH_METHOD, &dp, &v, &ei, &caller_sp);
2178c2c66affSColin Finck     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2179*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2180*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2181*7d76303dSAmine Khaldi     VariantClear(&v);
2182*7d76303dSAmine Khaldi     IDispatchEx_Release(proc);
2183c2c66affSColin Finck 
2184*7d76303dSAmine Khaldi     proc = parse_procedure(parse_proc, "\"foobar\"", SCRIPTPROC_ISEXPRESSION);
2185*7d76303dSAmine Khaldi 
2186*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2187*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2188*7d76303dSAmine Khaldi     hres = IDispatchEx_InvokeEx(proc, DISPID_VALUE, 0, DISPATCH_METHOD, &dp, &v, &ei, &caller_sp);
2189*7d76303dSAmine Khaldi     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2190*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2191*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2192*7d76303dSAmine Khaldi     ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR, got %s\n", vt2a(&v));
2193*7d76303dSAmine Khaldi     ok(!strcmp_wa(V_BSTR(&v), "foobar"), "Wrong string, got %s\n", wine_dbgstr_w(V_BSTR(&v)));
2194*7d76303dSAmine Khaldi     VariantClear(&v);
2195c2c66affSColin Finck     IDispatchEx_Release(proc);
2196c2c66affSColin Finck 
2197c2c66affSColin Finck     IActiveScriptParseProcedure2_Release(parse_proc);
2198c2c66affSColin Finck 
2199c2c66affSColin Finck     close_script(script);
2200*7d76303dSAmine Khaldi     strict_enter_script = FALSE;
2201*7d76303dSAmine Khaldi }
2202*7d76303dSAmine Khaldi 
free_ei(EXCEPINFO * ei)2203*7d76303dSAmine Khaldi static void free_ei(EXCEPINFO *ei)
2204*7d76303dSAmine Khaldi {
2205*7d76303dSAmine Khaldi     SysFreeString(ei->bstrSource);
2206*7d76303dSAmine Khaldi     SysFreeString(ei->bstrDescription);
2207*7d76303dSAmine Khaldi     SysFreeString(ei->bstrHelpFile);
2208*7d76303dSAmine Khaldi }
2209*7d76303dSAmine Khaldi 
test_callbacks(void)2210*7d76303dSAmine Khaldi static void test_callbacks(void)
2211*7d76303dSAmine Khaldi {
2212*7d76303dSAmine Khaldi     IActiveScriptError *error1, *error2;
2213*7d76303dSAmine Khaldi     IActiveScriptParse *parser;
2214*7d76303dSAmine Khaldi     DISPPARAMS dp = {NULL};
2215*7d76303dSAmine Khaldi     IActiveScript *script;
2216*7d76303dSAmine Khaldi     IDispatchEx *dispex;
2217*7d76303dSAmine Khaldi     IDispatch *disp;
2218*7d76303dSAmine Khaldi     DISPID id;
2219*7d76303dSAmine Khaldi     EXCEPINFO ei = {0};
2220*7d76303dSAmine Khaldi     BSTR str;
2221*7d76303dSAmine Khaldi     VARIANT v;
2222*7d76303dSAmine Khaldi     HRESULT hres;
2223*7d76303dSAmine Khaldi 
2224*7d76303dSAmine Khaldi     strict_enter_script = TRUE;
2225*7d76303dSAmine Khaldi     script = create_and_init_script(SCRIPTITEM_GLOBALMEMBERS, TRUE);
2226*7d76303dSAmine Khaldi 
2227*7d76303dSAmine Khaldi     hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser);
2228*7d76303dSAmine Khaldi     ok(hres == S_OK, "Could not get IActiveScriptParseProcedure2 iface: %08x\n", hres);
2229*7d76303dSAmine Khaldi 
2230*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2231*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2232*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser,
2233*7d76303dSAmine Khaldi                                               L"class CallbackClass\n"
2234*7d76303dSAmine Khaldi                                               L"    public function callback()\n"
2235*7d76303dSAmine Khaldi                                               L"        call ok(err.number = 2, \"err.number = \" & err.number)\n"
2236*7d76303dSAmine Khaldi                                               L"        callback = true\n"
2237*7d76303dSAmine Khaldi                                               L"    end function\n"
2238*7d76303dSAmine Khaldi                                               L"end class\n"
2239*7d76303dSAmine Khaldi                                               L"function callGlobalCallback()\n"
2240*7d76303dSAmine Khaldi                                               L"    on error resume next\n"
2241*7d76303dSAmine Khaldi                                               L"    err.raise 2\n"
2242*7d76303dSAmine Khaldi                                               L"    call test.globalCallback(new CallbackClass)\n"
2243*7d76303dSAmine Khaldi                                               L"    call ok(err.number = 2, \"err.number = \" & err.numner)\n"
2244*7d76303dSAmine Khaldi                                               L"end function\n",
2245*7d76303dSAmine Khaldi                                               NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2246*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2247*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2248*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2249*7d76303dSAmine Khaldi 
2250*7d76303dSAmine Khaldi     hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
2251*7d76303dSAmine Khaldi     ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
2252*7d76303dSAmine Khaldi 
2253*7d76303dSAmine Khaldi     hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
2254*7d76303dSAmine Khaldi     ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
2255*7d76303dSAmine Khaldi     IDispatch_Release(disp);
2256*7d76303dSAmine Khaldi 
2257*7d76303dSAmine Khaldi     str = SysAllocString(L"callGlobalCallback");
2258*7d76303dSAmine Khaldi     hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id);
2259*7d76303dSAmine Khaldi     ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
2260*7d76303dSAmine Khaldi     SysFreeString(str);
2261*7d76303dSAmine Khaldi 
2262*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2263*7d76303dSAmine Khaldi     /* OnLeaveScript will be set in global callback */
2264*7d76303dSAmine Khaldi     SET_EXPECT(global_globalcallback_i);
2265*7d76303dSAmine Khaldi     hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_METHOD, &dp, &v, &ei, &caller_sp);
2266*7d76303dSAmine Khaldi     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2267*7d76303dSAmine Khaldi     /* OnEnterScript was checked in global callback */
2268*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2269*7d76303dSAmine Khaldi     CHECK_CALLED(global_globalcallback_i);
2270*7d76303dSAmine Khaldi 
2271*7d76303dSAmine Khaldi     store_script_error = &error1;
2272*7d76303dSAmine Khaldi 
2273*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2274*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2275*7d76303dSAmine Khaldi     SET_EXPECT(OnScriptError);
2276*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, L"err.raise 2\n",
2277*7d76303dSAmine Khaldi                                               NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2278*7d76303dSAmine Khaldi     ok(hres == MAKE_VBSERROR(2), "ParseScriptText failed: %08x\n", hres);
2279*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2280*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2281*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2282*7d76303dSAmine Khaldi 
2283*7d76303dSAmine Khaldi     store_script_error = &error2;
2284*7d76303dSAmine Khaldi 
2285*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2286*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2287*7d76303dSAmine Khaldi     SET_EXPECT(OnScriptError);
2288*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser,
2289*7d76303dSAmine Khaldi                                               L"call ok(err.number = 0, \"err.number = \" & err.number)\n"
2290*7d76303dSAmine Khaldi                                               L"err.raise &h86664004&, \"src\", \"desc\", \"help\", 1\n",
2291*7d76303dSAmine Khaldi                                               NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2292*7d76303dSAmine Khaldi     ok(hres == SCRIPT_E_RECORDED, "ParseScriptText failed: %08x\n", hres);
2293*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2294*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2295*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2296*7d76303dSAmine Khaldi 
2297*7d76303dSAmine Khaldi     memset(&ei, 0xcc, sizeof(ei));
2298*7d76303dSAmine Khaldi     hres = IActiveScriptError_GetExceptionInfo(error1, &ei);
2299*7d76303dSAmine Khaldi     ok(hres == S_OK, "GetExceptionInfo returned %08x\n", hres);
2300*7d76303dSAmine Khaldi     ok(!ei.wCode, "wCode = %x\n", ei.wCode);
2301*7d76303dSAmine Khaldi     ok(!ei.wReserved, "wReserved = %x\n", ei.wReserved);
2302*7d76303dSAmine Khaldi     if(is_english) {
2303*7d76303dSAmine Khaldi         ok(!wcscmp(ei.bstrSource, L"Microsoft VBScript runtime error"),
2304*7d76303dSAmine Khaldi            "bstrSource = %s\n", wine_dbgstr_w(ei.bstrSource));
2305*7d76303dSAmine Khaldi         ok(!wcscmp(ei.bstrDescription, L"Object doesn't support this property or method"),
2306*7d76303dSAmine Khaldi            "bstrDescription = %s\n", wine_dbgstr_w(ei.bstrDescription));
2307*7d76303dSAmine Khaldi     }
2308*7d76303dSAmine Khaldi     ok(!ei.bstrHelpFile, "bstrHelpFile = %s\n", wine_dbgstr_w(ei.bstrHelpFile));
2309*7d76303dSAmine Khaldi     ok(!ei.dwHelpContext, "dwHelpContext = %x\n", ei.dwHelpContext);
2310*7d76303dSAmine Khaldi     ok(!ei.pvReserved, "pvReserved = %p\n", ei.pvReserved);
2311*7d76303dSAmine Khaldi     ok(!ei.pfnDeferredFillIn, "pfnDeferredFillIn = %p\n", ei.pfnDeferredFillIn);
2312*7d76303dSAmine Khaldi     ok(ei.scode == MAKE_VBSERROR(2), "scode = %x\n", ei.scode);
2313*7d76303dSAmine Khaldi     free_ei(&ei);
2314*7d76303dSAmine Khaldi 
2315*7d76303dSAmine Khaldi     IActiveScriptError_Release(error1);
2316*7d76303dSAmine Khaldi 
2317*7d76303dSAmine Khaldi     memset(&ei, 0xcc, sizeof(ei));
2318*7d76303dSAmine Khaldi     hres = IActiveScriptError_GetExceptionInfo(error2, &ei);
2319*7d76303dSAmine Khaldi     ok(hres == S_OK, "GetExceptionInfo returned %08x\n", hres);
2320*7d76303dSAmine Khaldi     ok(!ei.wCode, "wCode = %x\n", ei.wCode);
2321*7d76303dSAmine Khaldi     ok(!ei.wReserved, "wReserved = %x\n", ei.wReserved);
2322*7d76303dSAmine Khaldi     ok(!wcscmp(ei.bstrSource, L"src"), "bstrSource = %s\n", wine_dbgstr_w(ei.bstrSource));
2323*7d76303dSAmine Khaldi     ok(!wcscmp(ei.bstrDescription, L"desc"), "bstrDescription = %s\n", wine_dbgstr_w(ei.bstrDescription));
2324*7d76303dSAmine Khaldi     ok(!wcscmp(ei.bstrHelpFile, L"help"), "bstrHelpFile = %s\n", wine_dbgstr_w(ei.bstrHelpFile));
2325*7d76303dSAmine Khaldi     ok(ei.dwHelpContext == 1, "dwHelpContext = %x\n", ei.dwHelpContext);
2326*7d76303dSAmine Khaldi     ok(!ei.pvReserved, "pvReserved = %p\n", ei.pvReserved);
2327*7d76303dSAmine Khaldi     ok(!ei.pfnDeferredFillIn, "pfnDeferredFillIn = %p\n", ei.pfnDeferredFillIn);
2328*7d76303dSAmine Khaldi     ok(ei.scode == SCRIPT_E_RECORDED, "scode = %x\n", ei.scode);
2329*7d76303dSAmine Khaldi     free_ei(&ei);
2330*7d76303dSAmine Khaldi 
2331*7d76303dSAmine Khaldi     IActiveScriptError_Release(error2);
2332*7d76303dSAmine Khaldi 
2333*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2334*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2335*7d76303dSAmine Khaldi     SET_EXPECT(OnScriptError);
2336*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, L"err.raise &hffff&\n",
2337*7d76303dSAmine Khaldi                                               NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2338*7d76303dSAmine Khaldi     ok(hres == MAKE_VBSERROR(0xffff), "ParseScriptText failed: %08x\n", hres);
2339*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2340*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2341*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2342*7d76303dSAmine Khaldi 
2343*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2344*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2345*7d76303dSAmine Khaldi     SET_EXPECT(OnScriptError);
2346*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, L"err.raise &h80102030&\n",
2347*7d76303dSAmine Khaldi                                               NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2348*7d76303dSAmine Khaldi     ok(hres == 0x80102030, "ParseScriptText failed: %08x\n", hres);
2349*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2350*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2351*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2352*7d76303dSAmine Khaldi 
2353*7d76303dSAmine Khaldi     SET_EXPECT(OnEnterScript);
2354*7d76303dSAmine Khaldi     SET_EXPECT(global_testerrorobject_i);
2355*7d76303dSAmine Khaldi     SET_EXPECT(OnLeaveScript);
2356*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser,
2357*7d76303dSAmine Khaldi                                               L"on error resume next\n"
2358*7d76303dSAmine Khaldi                                               L"err.raise 1\n"
2359*7d76303dSAmine Khaldi                                               L"testErrorObject err\n",
2360*7d76303dSAmine Khaldi                                               NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2361*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2362*7d76303dSAmine Khaldi     CHECK_CALLED(OnEnterScript);
2363*7d76303dSAmine Khaldi     CHECK_CALLED(global_testerrorobject_i);
2364*7d76303dSAmine Khaldi     CHECK_CALLED(OnLeaveScript);
2365*7d76303dSAmine Khaldi 
2366*7d76303dSAmine Khaldi     IDispatchEx_Release(dispex);
2367*7d76303dSAmine Khaldi 
2368*7d76303dSAmine Khaldi     IActiveScriptParse_Release(parser);
2369*7d76303dSAmine Khaldi     close_script(script);
2370*7d76303dSAmine Khaldi     strict_enter_script = FALSE;
2371c2c66affSColin Finck }
2372c2c66affSColin Finck 
test_gc(void)2373c2c66affSColin Finck static void test_gc(void)
2374c2c66affSColin Finck {
2375c2c66affSColin Finck     IActiveScriptParse *parser;
2376c2c66affSColin Finck     IActiveScript *engine;
2377c2c66affSColin Finck     BSTR src;
2378c2c66affSColin Finck     HRESULT hres;
2379c2c66affSColin Finck 
2380c2c66affSColin Finck     strict_dispid_check = FALSE;
2381c2c66affSColin Finck 
2382c2c66affSColin Finck     engine = create_script();
2383c2c66affSColin Finck     if(!engine)
2384c2c66affSColin Finck         return;
2385c2c66affSColin Finck 
2386c2c66affSColin Finck     hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2387c2c66affSColin Finck     ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2388c2c66affSColin Finck 
2389c2c66affSColin Finck     hres = IActiveScriptParse_InitNew(parser);
2390c2c66affSColin Finck     ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2391c2c66affSColin Finck 
2392c2c66affSColin Finck     hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2393c2c66affSColin Finck     ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2394c2c66affSColin Finck 
2395c2c66affSColin Finck     hres = IActiveScript_AddNamedItem(engine, testW,
2396c2c66affSColin Finck             SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
2397c2c66affSColin Finck     ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2398c2c66affSColin Finck 
2399c2c66affSColin Finck     hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2400c2c66affSColin Finck     ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2401c2c66affSColin Finck 
2402c2c66affSColin Finck     src = a2bstr(
2403c2c66affSColin Finck             "class C\n"
2404c2c66affSColin Finck             "    Public ref\n"
2405c2c66affSColin Finck             "    Public Sub Class_Terminate\n"
2406c2c66affSColin Finck             "        Call reportSuccess()\n"
2407c2c66affSColin Finck             "    End Sub\n"
2408c2c66affSColin Finck             "End Class\n"
2409c2c66affSColin Finck             "Dim x\n"
2410c2c66affSColin Finck             "set x = new C\n"
2411c2c66affSColin Finck             "set x.ref = x\n"
2412c2c66affSColin Finck             "set x = nothing\n");
2413c2c66affSColin Finck 
2414c2c66affSColin Finck     hres = IActiveScriptParse_ParseScriptText(parser, src, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2415c2c66affSColin Finck     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2416c2c66affSColin Finck     SysFreeString(src);
2417c2c66affSColin Finck 
2418c2c66affSColin Finck     SET_EXPECT(global_success_d);
2419c2c66affSColin Finck     SET_EXPECT(global_success_i);
2420c2c66affSColin Finck     IActiveScript_Close(engine);
2421c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2422c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2423c2c66affSColin Finck 
2424c2c66affSColin Finck     IActiveScript_Release(engine);
2425c2c66affSColin Finck     IActiveScriptParse_Release(parser);
2426c2c66affSColin Finck }
2427c2c66affSColin Finck 
test_parse_errors(void)2428*7d76303dSAmine Khaldi static void test_parse_errors(void)
2429*7d76303dSAmine Khaldi {
2430*7d76303dSAmine Khaldi     static const char *invalid_scripts[] =
2431*7d76303dSAmine Khaldi     {
2432*7d76303dSAmine Khaldi         /* If...End If */
2433*7d76303dSAmine Khaldi         "If 0 > 1 Then\n"
2434*7d76303dSAmine Khaldi         "    x = 0 End If\n",
2435*7d76303dSAmine Khaldi 
2436*7d76303dSAmine Khaldi         /* While...End While */
2437*7d76303dSAmine Khaldi         "While False\n"
2438*7d76303dSAmine Khaldi         "    x = 0 End While\n",
2439*7d76303dSAmine Khaldi 
2440*7d76303dSAmine Khaldi         /* While...Wend */
2441*7d76303dSAmine Khaldi         "While False\n"
2442*7d76303dSAmine Khaldi         "    x = 0 Wend\n",
2443*7d76303dSAmine Khaldi 
2444*7d76303dSAmine Khaldi         /* Do While...Loop */
2445*7d76303dSAmine Khaldi         "Do While False\n"
2446*7d76303dSAmine Khaldi         "    x = 0 Loop\n",
2447*7d76303dSAmine Khaldi 
2448*7d76303dSAmine Khaldi         /* Do Until...Loop */
2449*7d76303dSAmine Khaldi         "Do Until True\n"
2450*7d76303dSAmine Khaldi         "    x = 0 Loop\n",
2451*7d76303dSAmine Khaldi 
2452*7d76303dSAmine Khaldi         /* Do...Loop While */
2453*7d76303dSAmine Khaldi         "Do\n"
2454*7d76303dSAmine Khaldi         "    x = 0 Loop While False\n",
2455*7d76303dSAmine Khaldi 
2456*7d76303dSAmine Khaldi         /* Do...Loop Until */
2457*7d76303dSAmine Khaldi         "Do\n"
2458*7d76303dSAmine Khaldi         "    x = 0 Loop Until True\n",
2459*7d76303dSAmine Khaldi 
2460*7d76303dSAmine Khaldi         /* Select...End Select */
2461*7d76303dSAmine Khaldi         "x = False\n"
2462*7d76303dSAmine Khaldi         "Select Case 42\n"
2463*7d76303dSAmine Khaldi         "    Case 0\n"
2464*7d76303dSAmine Khaldi         "        Call ok(False, \"unexpected case\")\n"
2465*7d76303dSAmine Khaldi         "    Case 42\n"
2466*7d76303dSAmine Khaldi         "        x = True End Select\n"
2467*7d76303dSAmine Khaldi         "Call ok(x, \"wrong case\")\n",
2468*7d76303dSAmine Khaldi 
2469*7d76303dSAmine Khaldi         /* Class...End Class  (empty) */
2470*7d76303dSAmine Khaldi         "Class C End Class"
2471*7d76303dSAmine Khaldi     };
2472*7d76303dSAmine Khaldi     HRESULT hres;
2473*7d76303dSAmine Khaldi     UINT i;
2474*7d76303dSAmine Khaldi 
2475*7d76303dSAmine Khaldi     for (i = 0; i < ARRAY_SIZE(invalid_scripts); i++)
2476*7d76303dSAmine Khaldi     {
2477*7d76303dSAmine Khaldi         SET_EXPECT(OnScriptError);
2478*7d76303dSAmine Khaldi         hres = parse_script_ar(invalid_scripts[i]);
2479*7d76303dSAmine Khaldi         ok(FAILED(hres), "[%u] script did not fail\n", i);
2480*7d76303dSAmine Khaldi         CHECK_CALLED(OnScriptError);
2481*7d76303dSAmine Khaldi     }
2482*7d76303dSAmine Khaldi }
2483*7d76303dSAmine Khaldi 
test_msgbox(void)2484c2c66affSColin Finck static void test_msgbox(void)
2485c2c66affSColin Finck {
2486c2c66affSColin Finck     HRESULT hres;
2487c2c66affSColin Finck 
2488c2c66affSColin Finck     uic_handling = SCRIPTUICHANDLING_NOUIDEFAULT;
2489c2c66affSColin Finck 
2490c2c66affSColin Finck     SET_EXPECT(GetUIBehavior);
2491c2c66affSColin Finck     SET_EXPECT(GetWindow);
2492c2c66affSColin Finck     SET_EXPECT(EnableModeless);
2493c2c66affSColin Finck     hres = parse_script_ar("MsgBox \"testing...\"");
2494c2c66affSColin Finck     CLEAR_CALLED(GetUIBehavior);
2495c2c66affSColin Finck     CLEAR_CALLED(GetWindow);
2496c2c66affSColin Finck     CLEAR_CALLED(EnableModeless);
2497c2c66affSColin Finck     if(FAILED(hres)) {
2498c2c66affSColin Finck         win_skip("Skipping MsgBox tests, broken (probably too old) vbscript\n");
2499c2c66affSColin Finck         return;
2500c2c66affSColin Finck     }
2501c2c66affSColin Finck 
2502c2c66affSColin Finck     SET_EXPECT(GetUIBehavior);
2503c2c66affSColin Finck     parse_script_a("dim r\n r=MsgBox(\"testing...\")\n Call ok(r=0, \"r=\"&r)");
2504c2c66affSColin Finck     CHECK_CALLED(GetUIBehavior);
2505c2c66affSColin Finck 
2506c2c66affSColin Finck     SET_EXPECT(GetUIBehavior);
2507c2c66affSColin Finck     parse_script_a("MsgBox 10");
2508c2c66affSColin Finck     CHECK_CALLED(GetUIBehavior);
2509c2c66affSColin Finck 
2510c2c66affSColin Finck     uic_handling = SCRIPTUICHANDLING_ALLOW;
2511c2c66affSColin Finck 
2512c2c66affSColin Finck     SET_EXPECT(GetUIBehavior);
2513c2c66affSColin Finck     SET_EXPECT(GetWindow);
2514c2c66affSColin Finck     SET_EXPECT(EnableModeless);
2515c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2516c2c66affSColin Finck     hres = parse_script_ar("MsgBox \"testing...\"");
2517c2c66affSColin Finck     ok(FAILED(hres), "script not failed\n");
2518c2c66affSColin Finck     CHECK_CALLED(GetUIBehavior);
2519c2c66affSColin Finck     CHECK_CALLED(GetWindow);
2520c2c66affSColin Finck     CHECK_CALLED(EnableModeless);
2521*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2522c2c66affSColin Finck 
2523c2c66affSColin Finck     uic_handling = SCRIPTUICHANDLING_NOUIERROR;
2524c2c66affSColin Finck 
2525c2c66affSColin Finck     SET_EXPECT(GetUIBehavior);
2526c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2527c2c66affSColin Finck     hres = parse_script_ar("MsgBox \"testing...\"");
2528c2c66affSColin Finck     ok(FAILED(hres), "script not failed\n");
2529c2c66affSColin Finck     CHECK_CALLED(GetUIBehavior);
2530*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2531c2c66affSColin Finck }
2532c2c66affSColin Finck 
test_global_vars_ref(BOOL use_close)2533c2c66affSColin Finck static HRESULT test_global_vars_ref(BOOL use_close)
2534c2c66affSColin Finck {
2535c2c66affSColin Finck     IActiveScriptParse *parser;
2536c2c66affSColin Finck     IActiveScript *engine;
2537c2c66affSColin Finck     BSTR script_str;
2538c2c66affSColin Finck     LONG ref;
2539c2c66affSColin Finck     HRESULT hres;
2540c2c66affSColin Finck 
2541c2c66affSColin Finck     engine = create_script();
2542c2c66affSColin Finck     if(!engine)
2543c2c66affSColin Finck         return S_OK;
2544c2c66affSColin Finck 
2545c2c66affSColin Finck     hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2546c2c66affSColin Finck     ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2547c2c66affSColin Finck     if (FAILED(hres))
2548c2c66affSColin Finck     {
2549c2c66affSColin Finck         IActiveScript_Release(engine);
2550c2c66affSColin Finck         return hres;
2551c2c66affSColin Finck     }
2552c2c66affSColin Finck 
2553c2c66affSColin Finck     hres = IActiveScriptParse_InitNew(parser);
2554c2c66affSColin Finck     ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2555c2c66affSColin Finck 
2556c2c66affSColin Finck     hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2557c2c66affSColin Finck     ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2558c2c66affSColin Finck 
2559c2c66affSColin Finck     hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
2560c2c66affSColin Finck     ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2561c2c66affSColin Finck 
2562c2c66affSColin Finck     hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2563c2c66affSColin Finck     ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2564c2c66affSColin Finck 
2565c2c66affSColin Finck     refobj_ref = 0;
2566c2c66affSColin Finck 
2567c2c66affSColin Finck     script_str = a2bstr("Dim x\nset x = RefObj\n");
2568c2c66affSColin Finck     hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2569c2c66affSColin Finck     SysFreeString(script_str);
2570c2c66affSColin Finck 
2571c2c66affSColin Finck     ok(refobj_ref, "refobj_ref = 0\n");
2572c2c66affSColin Finck 
2573c2c66affSColin Finck     if(use_close) {
2574c2c66affSColin Finck         hres = IActiveScript_Close(engine);
2575c2c66affSColin Finck         ok(hres == S_OK, "Close failed: %08x\n", hres);
2576c2c66affSColin Finck     }else {
2577c2c66affSColin Finck         hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_UNINITIALIZED);
2578c2c66affSColin Finck         ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2579c2c66affSColin Finck     }
2580c2c66affSColin Finck 
2581c2c66affSColin Finck     ok(!refobj_ref, "refobj_ref = %d\n", refobj_ref);
2582c2c66affSColin Finck 
2583c2c66affSColin Finck     IActiveScript_Release(engine);
2584c2c66affSColin Finck 
2585c2c66affSColin Finck     ref = IActiveScriptParse_Release(parser);
2586c2c66affSColin Finck     ok(!ref, "ref=%d\n", ref);
2587c2c66affSColin Finck     return hres;
2588c2c66affSColin Finck }
2589c2c66affSColin Finck 
test_isexpression(void)2590*7d76303dSAmine Khaldi static void test_isexpression(void)
2591*7d76303dSAmine Khaldi {
2592*7d76303dSAmine Khaldi     IActiveScriptParse *parser;
2593*7d76303dSAmine Khaldi     IActiveScript *engine;
2594*7d76303dSAmine Khaldi     SCRIPTSTATE ss;
2595*7d76303dSAmine Khaldi     HRESULT hres;
2596*7d76303dSAmine Khaldi     VARIANT var;
2597*7d76303dSAmine Khaldi     BSTR str;
2598*7d76303dSAmine Khaldi 
2599*7d76303dSAmine Khaldi     if (!(engine = create_and_init_script(0, FALSE)))
2600*7d76303dSAmine Khaldi         return;
2601*7d76303dSAmine Khaldi 
2602*7d76303dSAmine Khaldi     hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2603*7d76303dSAmine Khaldi     ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2604*7d76303dSAmine Khaldi     if (FAILED(hres))
2605*7d76303dSAmine Khaldi     {
2606*7d76303dSAmine Khaldi         close_script(engine);
2607*7d76303dSAmine Khaldi         return;
2608*7d76303dSAmine Khaldi     }
2609*7d76303dSAmine Khaldi 
2610*7d76303dSAmine Khaldi     /* Expression when script is not started is still executed */
2611*7d76303dSAmine Khaldi     hres = IActiveScript_GetScriptState(engine, &ss);
2612*7d76303dSAmine Khaldi     ok(hres == S_OK, "GetScriptState failed: %08x\n", hres);
2613*7d76303dSAmine Khaldi     ok(ss == SCRIPTSTATE_INITIALIZED, "Wrong script state %u\n", ss);
2614*7d76303dSAmine Khaldi 
2615*7d76303dSAmine Khaldi     str = a2bstr("13");
2616*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2617*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2618*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_I2, "Expected VT_I2, got %s\n", vt2a(&var));
2619*7d76303dSAmine Khaldi     ok(V_I2(&var) == 13, "Expected 13, got %d\n", V_I2(&var));
2620*7d76303dSAmine Khaldi     VariantClear(&var);
2621*7d76303dSAmine Khaldi     SysFreeString(str);
2622*7d76303dSAmine Khaldi 
2623*7d76303dSAmine Khaldi     hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2624*7d76303dSAmine Khaldi     ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2625*7d76303dSAmine Khaldi 
2626*7d76303dSAmine Khaldi     /* Empty expressions */
2627*7d76303dSAmine Khaldi     V_VT(&var) = VT_I2;
2628*7d76303dSAmine Khaldi     str = a2bstr("");
2629*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2630*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2631*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_EMPTY, "Expected VT_EMPTY, got %s\n", vt2a(&var));
2632*7d76303dSAmine Khaldi     VariantClear(&var);
2633*7d76303dSAmine Khaldi     SysFreeString(str);
2634*7d76303dSAmine Khaldi 
2635*7d76303dSAmine Khaldi     /* Two expressions fail */
2636*7d76303dSAmine Khaldi     str = a2bstr("1\n3");
2637*7d76303dSAmine Khaldi     SET_EXPECT(OnScriptError);
2638*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2639*7d76303dSAmine Khaldi     ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres);
2640*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2641*7d76303dSAmine Khaldi     VariantClear(&var);
2642*7d76303dSAmine Khaldi     SysFreeString(str);
2643*7d76303dSAmine Khaldi 
2644*7d76303dSAmine Khaldi     /* Simple numerical expression */
2645*7d76303dSAmine Khaldi     str = a2bstr("(1 + 7) * 2 - 3");
2646*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, NULL, NULL);
2647*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2648*7d76303dSAmine Khaldi 
2649*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2650*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2651*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_I2, "Expected VT_I2, got %s\n", vt2a(&var));
2652*7d76303dSAmine Khaldi     ok(V_I2(&var) == 13, "Expected 13, got %d\n", V_I2(&var));
2653*7d76303dSAmine Khaldi     VariantClear(&var);
2654*7d76303dSAmine Khaldi     SysFreeString(str);
2655*7d76303dSAmine Khaldi 
2656*7d76303dSAmine Khaldi     /* An expression can also refer to a variable, function, class, etc previously set */
2657*7d76303dSAmine Khaldi     V_VT(&var) = VT_I2;
2658*7d76303dSAmine Khaldi     str = a2bstr("If True Then foo = 42 Else foo = 0\n");
2659*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, &var, NULL);
2660*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2661*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_EMPTY, "Expected VT_EMPTY, got %s\n", vt2a(&var));
2662*7d76303dSAmine Khaldi     VariantClear(&var);
2663*7d76303dSAmine Khaldi     SysFreeString(str);
2664*7d76303dSAmine Khaldi 
2665*7d76303dSAmine Khaldi     str = a2bstr("foo\n\n");
2666*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2667*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2668*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_I2, "Expected VT_I2, got %s\n", vt2a(&var));
2669*7d76303dSAmine Khaldi     ok(V_I2(&var) == 42, "Expected 42, got %d\n", V_I2(&var));
2670*7d76303dSAmine Khaldi     VariantClear(&var);
2671*7d76303dSAmine Khaldi     SysFreeString(str);
2672*7d76303dSAmine Khaldi 
2673*7d76303dSAmine Khaldi     str = a2bstr("foo : ");
2674*7d76303dSAmine Khaldi     SET_EXPECT(OnScriptError);
2675*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2676*7d76303dSAmine Khaldi     ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres);
2677*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2678*7d76303dSAmine Khaldi     VariantClear(&var);
2679*7d76303dSAmine Khaldi     SysFreeString(str);
2680*7d76303dSAmine Khaldi 
2681*7d76303dSAmine Khaldi     str = a2bstr("\"foo is \" & CStr(foo)  \n  \n\n ");
2682*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2683*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2684*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_BSTR, "Expected VT_BSTR, got %s\n", vt2a(&var));
2685*7d76303dSAmine Khaldi     ok(!strcmp_wa(V_BSTR(&var), "foo is 42"), "Wrong string, got %s\n", wine_dbgstr_w(V_BSTR(&var)));
2686*7d76303dSAmine Khaldi     VariantClear(&var);
2687*7d76303dSAmine Khaldi     SysFreeString(str);
2688*7d76303dSAmine Khaldi 
2689*7d76303dSAmine Khaldi     str = a2bstr("Function test(x)\n"
2690*7d76303dSAmine Khaldi                  "    test = x + 0.5\n"
2691*7d76303dSAmine Khaldi                  "End Function\n");
2692*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2693*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2694*7d76303dSAmine Khaldi     SysFreeString(str);
2695*7d76303dSAmine Khaldi 
2696*7d76303dSAmine Khaldi     str = a2bstr("test(4) * 3\n");
2697*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2698*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2699*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_R8, "Expected VT_R8, got %s\n", vt2a(&var));
2700*7d76303dSAmine Khaldi     ok(V_R8(&var) == 13.5, "Expected %lf, got %lf\n", 13.5, V_R8(&var));
2701*7d76303dSAmine Khaldi     VariantClear(&var);
2702*7d76303dSAmine Khaldi     SysFreeString(str);
2703*7d76303dSAmine Khaldi 
2704*7d76303dSAmine Khaldi     str = a2bstr("Class C\n"
2705*7d76303dSAmine Khaldi                  "    Public x\n"
2706*7d76303dSAmine Khaldi                  "End Class\n"
2707*7d76303dSAmine Khaldi                  "Set obj = New C\n"
2708*7d76303dSAmine Khaldi                  "obj.x = True\n");
2709*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2710*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2711*7d76303dSAmine Khaldi     SysFreeString(str);
2712*7d76303dSAmine Khaldi 
2713*7d76303dSAmine Khaldi     str = a2bstr("obj.x");
2714*7d76303dSAmine Khaldi     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
2715*7d76303dSAmine Khaldi     ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2716*7d76303dSAmine Khaldi     ok(V_VT(&var) == VT_BOOL, "Expected VT_BOOL, got %s\n", vt2a(&var));
2717*7d76303dSAmine Khaldi     ok(V_BOOL(&var) == VARIANT_TRUE, "Expected %x, got %x\n", VARIANT_TRUE, V_BOOL(&var));
2718*7d76303dSAmine Khaldi     VariantClear(&var);
2719*7d76303dSAmine Khaldi     SysFreeString(str);
2720*7d76303dSAmine Khaldi 
2721*7d76303dSAmine Khaldi     IActiveScriptParse_Release(parser);
2722*7d76303dSAmine Khaldi     close_script(engine);
2723*7d76303dSAmine Khaldi }
2724*7d76303dSAmine Khaldi 
get_script_from_file(const char * filename)2725c2c66affSColin Finck static BSTR get_script_from_file(const char *filename)
2726c2c66affSColin Finck {
2727c2c66affSColin Finck     DWORD size, len;
2728c2c66affSColin Finck     HANDLE file, map;
2729c2c66affSColin Finck     const char *file_map;
2730c2c66affSColin Finck     BSTR ret;
2731c2c66affSColin Finck 
2732c2c66affSColin Finck     file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
2733c2c66affSColin Finck     if(file == INVALID_HANDLE_VALUE) {
2734c2c66affSColin Finck         trace("Could not open file: %u\n", GetLastError());
2735c2c66affSColin Finck         return NULL;
2736c2c66affSColin Finck     }
2737c2c66affSColin Finck 
2738c2c66affSColin Finck     size = GetFileSize(file, NULL);
2739c2c66affSColin Finck 
2740c2c66affSColin Finck     map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
2741c2c66affSColin Finck     CloseHandle(file);
2742c2c66affSColin Finck     if(map == INVALID_HANDLE_VALUE) {
2743c2c66affSColin Finck         trace("Could not create file mapping: %u\n", GetLastError());
2744c2c66affSColin Finck         return NULL;
2745c2c66affSColin Finck     }
2746c2c66affSColin Finck 
2747c2c66affSColin Finck     file_map = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
2748c2c66affSColin Finck     CloseHandle(map);
2749c2c66affSColin Finck     if(!file_map) {
2750c2c66affSColin Finck         trace("MapViewOfFile failed: %u\n", GetLastError());
2751c2c66affSColin Finck         return NULL;
2752c2c66affSColin Finck     }
2753c2c66affSColin Finck 
2754c2c66affSColin Finck     len = MultiByteToWideChar(CP_ACP, 0, file_map, size, NULL, 0);
2755c2c66affSColin Finck     ret = SysAllocStringLen(NULL, len);
2756c2c66affSColin Finck     MultiByteToWideChar(CP_ACP, 0, file_map, size, ret, len);
2757c2c66affSColin Finck 
2758c2c66affSColin Finck     UnmapViewOfFile(file_map);
2759c2c66affSColin Finck 
2760c2c66affSColin Finck     return ret;
2761c2c66affSColin Finck }
2762c2c66affSColin Finck 
run_from_file(const char * filename)2763c2c66affSColin Finck static void run_from_file(const char *filename)
2764c2c66affSColin Finck {
2765c2c66affSColin Finck     BSTR script_str;
2766c2c66affSColin Finck     HRESULT hres;
2767c2c66affSColin Finck 
2768c2c66affSColin Finck     script_str = get_script_from_file(filename);
2769c2c66affSColin Finck     if(!script_str)
2770c2c66affSColin Finck         return;
2771c2c66affSColin Finck 
2772c2c66affSColin Finck     strict_dispid_check = FALSE;
2773c2c66affSColin Finck     hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str, NULL);
2774c2c66affSColin Finck     SysFreeString(script_str);
2775c2c66affSColin Finck     ok(hres == S_OK, "parse_script failed: %08x\n", hres);
2776c2c66affSColin Finck }
2777c2c66affSColin Finck 
run_from_res(const char * name)2778c2c66affSColin Finck static void run_from_res(const char *name)
2779c2c66affSColin Finck {
2780c2c66affSColin Finck     const char *data;
2781c2c66affSColin Finck     DWORD size, len;
2782c2c66affSColin Finck     BSTR str;
2783c2c66affSColin Finck     HRSRC src;
2784c2c66affSColin Finck     HRESULT hres;
2785c2c66affSColin Finck 
2786c2c66affSColin Finck     strict_dispid_check = FALSE;
2787c2c66affSColin Finck     test_name = name;
2788c2c66affSColin Finck 
2789c2c66affSColin Finck     src = FindResourceA(NULL, name, (LPCSTR)40);
2790c2c66affSColin Finck     ok(src != NULL, "Could not find resource %s\n", name);
2791c2c66affSColin Finck 
2792c2c66affSColin Finck     size = SizeofResource(NULL, src);
2793c2c66affSColin Finck     data = LoadResource(NULL, src);
2794c2c66affSColin Finck 
2795c2c66affSColin Finck     len = MultiByteToWideChar(CP_ACP, 0, data, size, NULL, 0);
2796c2c66affSColin Finck     str = SysAllocStringLen(NULL, len);
2797c2c66affSColin Finck     MultiByteToWideChar(CP_ACP, 0, data, size, str, len);
2798c2c66affSColin Finck 
2799c2c66affSColin Finck     SET_EXPECT(global_success_d);
2800c2c66affSColin Finck     SET_EXPECT(global_success_i);
2801c2c66affSColin Finck     hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, str, NULL);
2802c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2803c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2804c2c66affSColin Finck 
2805c2c66affSColin Finck     ok(hres == S_OK, "parse_script failed: %08x\n", hres);
2806c2c66affSColin Finck     SysFreeString(str);
2807*7d76303dSAmine Khaldi     test_name = "";
2808c2c66affSColin Finck }
2809c2c66affSColin Finck 
run_tests(void)2810c2c66affSColin Finck static void run_tests(void)
2811c2c66affSColin Finck {
2812c2c66affSColin Finck     HRESULT hres;
2813c2c66affSColin Finck 
2814c2c66affSColin Finck     strict_dispid_check = TRUE;
2815c2c66affSColin Finck 
2816c2c66affSColin Finck     parse_script_a("");
2817c2c66affSColin Finck     parse_script_a("' empty ;");
2818c2c66affSColin Finck 
2819c2c66affSColin Finck     SET_EXPECT(global_success_d);
2820c2c66affSColin Finck     SET_EXPECT(global_success_i);
2821c2c66affSColin Finck     parse_script_a("reportSuccess");
2822c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2823c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2824c2c66affSColin Finck 
2825c2c66affSColin Finck     SET_EXPECT(global_success_d);
2826c2c66affSColin Finck     SET_EXPECT(global_success_i);
2827c2c66affSColin Finck     parse_script_a("reportSuccess()");
2828c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2829c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2830c2c66affSColin Finck 
2831c2c66affSColin Finck     SET_EXPECT(global_success_d);
2832c2c66affSColin Finck     SET_EXPECT(global_success_i);
2833c2c66affSColin Finck     parse_script_a("Call reportSuccess");
2834c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2835c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2836c2c66affSColin Finck 
2837c2c66affSColin Finck     SET_EXPECT(global_success_d);
2838c2c66affSColin Finck     SET_EXPECT(global_success_i);
2839c2c66affSColin Finck     parse_script_a("test.reportSuccess()");
2840c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2841c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2842c2c66affSColin Finck 
2843c2c66affSColin Finck     SET_EXPECT(global_success_d);
2844c2c66affSColin Finck     SET_EXPECT(global_success_i);
2845c2c66affSColin Finck     parse_script_af(0, "TEST.reportSuccess()");
2846c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2847c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2848c2c66affSColin Finck 
2849c2c66affSColin Finck     SET_EXPECT(global_vbvar_d);
2850c2c66affSColin Finck     SET_EXPECT(global_vbvar_i);
2851c2c66affSColin Finck     parse_script_a("Option Explicit\nvbvar = 3");
2852c2c66affSColin Finck     CHECK_CALLED(global_vbvar_d);
2853c2c66affSColin Finck     CHECK_CALLED(global_vbvar_i);
2854c2c66affSColin Finck 
2855c2c66affSColin Finck     SET_EXPECT(global_vbvar_d);
2856c2c66affSColin Finck     SET_EXPECT(global_vbvar_i);
2857c2c66affSColin Finck     parse_script_a("Option Explicit\nvbvar() = 3");
2858c2c66affSColin Finck     CHECK_CALLED(global_vbvar_d);
2859c2c66affSColin Finck     CHECK_CALLED(global_vbvar_i);
2860c2c66affSColin Finck 
2861c2c66affSColin Finck     SET_EXPECT(global_letobj_i);
2862c2c66affSColin Finck     parse_script_a("Option Explicit\nletobj = testObj");
2863c2c66affSColin Finck     CHECK_CALLED(global_letobj_i);
2864c2c66affSColin Finck 
2865c2c66affSColin Finck     SET_EXPECT(global_letobj_i);
2866c2c66affSColin Finck     parse_script_a("Option Explicit\ntest.letobj = testObj");
2867c2c66affSColin Finck     CHECK_CALLED(global_letobj_i);
2868c2c66affSColin Finck 
2869c2c66affSColin Finck     SET_EXPECT(global_setobj_i);
2870c2c66affSColin Finck     parse_script_a("Option Explicit\nset setobj = testObj");
2871c2c66affSColin Finck     CHECK_CALLED(global_setobj_i);
2872c2c66affSColin Finck 
2873c2c66affSColin Finck     SET_EXPECT(global_setobj_i);
2874c2c66affSColin Finck     parse_script_a("Option Explicit\nset test.setobj = testObj");
2875c2c66affSColin Finck     CHECK_CALLED(global_setobj_i);
2876c2c66affSColin Finck 
2877*7d76303dSAmine Khaldi     SET_EXPECT(OnScriptError);
2878*7d76303dSAmine Khaldi     hres = parse_script_ar("dim x\nx = testObj.rem");
2879*7d76303dSAmine Khaldi     todo_wine
2880*7d76303dSAmine Khaldi     ok(hres == S_OK, "use of 'rem' as dot identifier failed: %x08\n", hres);
2881*7d76303dSAmine Khaldi     todo_wine
2882*7d76303dSAmine Khaldi     CHECK_NOT_CALLED(OnScriptError);
2883*7d76303dSAmine Khaldi 
2884c2c66affSColin Finck     SET_EXPECT(testobj_propget_d);
2885c2c66affSColin Finck     SET_EXPECT(testobj_propget_i);
2886c2c66affSColin Finck     parse_script_a("dim x\nx = testObj.propget");
2887c2c66affSColin Finck     CHECK_CALLED(testobj_propget_d);
2888c2c66affSColin Finck     CHECK_CALLED(testobj_propget_i);
2889c2c66affSColin Finck 
2890c2c66affSColin Finck     SET_EXPECT(testobj_propput_d);
2891c2c66affSColin Finck     SET_EXPECT(testobj_propput_i);
2892c2c66affSColin Finck     parse_script_a("testObj.propput = 1");
2893c2c66affSColin Finck     CHECK_CALLED(testobj_propput_d);
2894c2c66affSColin Finck     CHECK_CALLED(testobj_propput_i);
2895c2c66affSColin Finck 
2896c2c66affSColin Finck     SET_EXPECT(global_propargput_d);
2897c2c66affSColin Finck     SET_EXPECT(global_propargput_i);
2898c2c66affSColin Finck     parse_script_a("propargput(counter(), counter()) = counter()");
2899c2c66affSColin Finck     CHECK_CALLED(global_propargput_d);
2900c2c66affSColin Finck     CHECK_CALLED(global_propargput_i);
2901c2c66affSColin Finck 
2902c2c66affSColin Finck     SET_EXPECT(global_propargput_d);
2903c2c66affSColin Finck     SET_EXPECT(global_propargput_i);
2904c2c66affSColin Finck     parse_script_a("test.propargput(counter(), counter()) = counter()");
2905c2c66affSColin Finck     CHECK_CALLED(global_propargput_d);
2906c2c66affSColin Finck     CHECK_CALLED(global_propargput_i);
2907c2c66affSColin Finck 
2908c2c66affSColin Finck     SET_EXPECT(global_propargput1_d);
2909c2c66affSColin Finck     SET_EXPECT(global_propargput1_i);
2910c2c66affSColin Finck     parse_script_a("propargput1 (counter()) = counter()");
2911c2c66affSColin Finck     CHECK_CALLED(global_propargput1_d);
2912c2c66affSColin Finck     CHECK_CALLED(global_propargput1_i);
2913c2c66affSColin Finck 
2914c2c66affSColin Finck     SET_EXPECT(global_propargput1_d);
2915c2c66affSColin Finck     SET_EXPECT(global_propargput1_i);
2916c2c66affSColin Finck     parse_script_a("test.propargput1(counter()) = counter()");
2917c2c66affSColin Finck     CHECK_CALLED(global_propargput1_d);
2918c2c66affSColin Finck     CHECK_CALLED(global_propargput1_i);
2919c2c66affSColin Finck 
2920c2c66affSColin Finck     parse_htmlscript_a("<!--");
2921c2c66affSColin Finck     parse_htmlscript_a(" -->");
2922c2c66affSColin Finck     parse_htmlscript_a("<!--\ndim x\nx=1\n-->\n");
2923c2c66affSColin Finck     parse_htmlscript_a("<!--\ndim x\n-->\n<!--\nx=1\n-->\n");
2924c2c66affSColin Finck 
2925c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2926c2c66affSColin Finck     hres = parse_script_ar("<!--");
2927c2c66affSColin Finck     ok(FAILED(hres), "script didn't fail\n");
2928*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2929c2c66affSColin Finck 
2930c2c66affSColin Finck     SET_EXPECT(global_success_d);
2931c2c66affSColin Finck     SET_EXPECT(global_success_i);
2932c2c66affSColin Finck     parse_htmlscript_a("<!--\n<!-- ignore this <> <>\n--> <>\nCall reportSuccess()\n-->\n");
2933c2c66affSColin Finck     CHECK_CALLED(global_success_d);
2934c2c66affSColin Finck     CHECK_CALLED(global_success_i);
2935c2c66affSColin Finck 
2936c2c66affSColin Finck     next_cnt = 0;
2937c2c66affSColin Finck     SET_EXPECT(collectionobj_newenum_i);
2938c2c66affSColin Finck     SET_EXPECT(Next);
2939c2c66affSColin Finck     parse_script_a("for each x in collectionObj\nnext");
2940c2c66affSColin Finck     CHECK_CALLED(collectionobj_newenum_i);
2941c2c66affSColin Finck     CHECK_CALLED(Next);
2942c2c66affSColin Finck     ok(next_cnt == 4, "next_cnt = %d\n", next_cnt);
2943c2c66affSColin Finck 
2944c2c66affSColin Finck     parse_script_a("x = 1\n Call ok(x = 1, \"x = \" & x)");
2945c2c66affSColin Finck 
2946c2c66affSColin Finck     parse_script_a("x = _    \n3");
2947c2c66affSColin Finck 
2948c2c66affSColin Finck     test_global_vars_ref(TRUE);
2949c2c66affSColin Finck     test_global_vars_ref(FALSE);
2950c2c66affSColin Finck 
2951c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2952c2c66affSColin Finck     hres = parse_script_ar("throwInt(&h80080008&)");
2953c2c66affSColin Finck     ok(hres == 0x80080008, "hres = %08x\n", hres);
2954*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2955c2c66affSColin Finck 
2956c2c66affSColin Finck     /* DISP_E_BADINDEX */
2957c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2958c2c66affSColin Finck     hres = parse_script_ar("throwInt(&h8002000b&)");
2959c2c66affSColin Finck     ok(hres == MAKE_VBSERROR(9), "hres = %08x\n", hres);
2960*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2961c2c66affSColin Finck 
2962c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2963c2c66affSColin Finck     hres = parse_script_ar("throwInt(&h800a0009&)");
2964c2c66affSColin Finck     ok(hres == MAKE_VBSERROR(9), "hres = %08x\n", hres);
2965*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2966c2c66affSColin Finck 
2967c2c66affSColin Finck     onerror_hres = S_OK;
2968c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2969c2c66affSColin Finck     hres = parse_script_ar("throwInt(&h800a0009&)");
2970*7d76303dSAmine Khaldi     ok(hres == SCRIPT_E_REPORTED, "hres = %08x\n", hres);
2971*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2972c2c66affSColin Finck 
2973c2c66affSColin Finck     /* E_NOTIMPL */
2974c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2975c2c66affSColin Finck     hres = parse_script_ar("throwInt(&h80004001&)");
2976c2c66affSColin Finck     ok(hres == MAKE_VBSERROR(445), "hres = %08x\n", hres);
2977*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2978c2c66affSColin Finck 
2979c2c66affSColin Finck     onerror_hres = S_OK;
2980c2c66affSColin Finck     SET_EXPECT(OnScriptError);
2981c2c66affSColin Finck     hres = parse_script_ar("throwInt(&h80004001&)");
2982*7d76303dSAmine Khaldi     ok(hres == SCRIPT_E_REPORTED, "hres = %08x\n", hres);
2983*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
2984c2c66affSColin Finck 
2985c2c66affSColin Finck     SET_EXPECT(global_testoptionalarg_i);
2986c2c66affSColin Finck     parse_script_a("call testOptionalArg(1,,2)");
2987c2c66affSColin Finck     CHECK_CALLED(global_testoptionalarg_i);
2988c2c66affSColin Finck 
2989c2c66affSColin Finck     SET_EXPECT(global_testoptionalarg_i);
2990c2c66affSColin Finck     parse_script_a("call testOptionalArg(,1,1)");
2991c2c66affSColin Finck     CHECK_CALLED(global_testoptionalarg_i);
2992c2c66affSColin Finck 
2993c2c66affSColin Finck     SET_EXPECT(global_testoptionalarg_i);
2994c2c66affSColin Finck     parse_script_a("testOptionalArg 1,,2");
2995c2c66affSColin Finck     CHECK_CALLED(global_testoptionalarg_i);
2996c2c66affSColin Finck 
2997c2c66affSColin Finck     strict_dispid_check = FALSE;
2998c2c66affSColin Finck 
2999c2c66affSColin Finck     SET_EXPECT(testobj_value_i);
3000c2c66affSColin Finck     parse_script_a("dim n,o\n set o = testObj\n n = o(1,2)\n call ok(n=2, \"n = \" & n)\n");
3001c2c66affSColin Finck     CHECK_CALLED(testobj_value_i);
3002c2c66affSColin Finck 
3003c2c66affSColin Finck     SET_EXPECT(testobj_value_i);
3004c2c66affSColin Finck     parse_script_a("dim n,o\n set o = testObj\n n = o\n call ok(n=0, \"n = \" & n)\n");
3005c2c66affSColin Finck     CHECK_CALLED(testobj_value_i);
3006c2c66affSColin Finck 
3007c2c66affSColin Finck     parse_script_a("Sub testsub\n"
3008c2c66affSColin Finck                    "x = 1\n"
3009c2c66affSColin Finck                    "Call ok(x = 1, \"x = \" & x)\n"
3010c2c66affSColin Finck                    "End Sub\n"
3011c2c66affSColin Finck                    "Call testsub()");
3012c2c66affSColin Finck 
3013c2c66affSColin Finck     parse_script_a("Call ok(getVT(x) = \"VT_EMPTY*\", \"getVT(x) = \" & getVT(x))\n");
3014c2c66affSColin Finck     parse_script_a("Call ok(x = \"\", \"x = \" & x)\n");
3015c2c66affSColin Finck     parse_script_a("x = y\n"
3016c2c66affSColin Finck                    "Call ok(getVT(x) = \"VT_EMPTY*\", \"getVT(x) = \" & getVT(x))\n"
3017c2c66affSColin Finck                    "Call ok(getVT(y) = \"VT_EMPTY*\", \"getVT(y) = \" & getVT(y))");
3018c2c66affSColin Finck     SET_EXPECT(OnScriptError);
3019c2c66affSColin Finck     hres = parse_script_ar("x = y(\"a\")");
3020c2c66affSColin Finck     ok(FAILED(hres), "script didn't fail\n");
3021*7d76303dSAmine Khaldi     CHECK_CALLED(OnScriptError);
3022c2c66affSColin Finck 
3023827f6644SAmine Khaldi     SET_EXPECT(global_success_d);
3024827f6644SAmine Khaldi     SET_EXPECT(global_success_i);
3025827f6644SAmine Khaldi     parse_script_a("' comment\r"
3026*7d76303dSAmine Khaldi                    "x = _\r3\r"
3027*7d76303dSAmine Khaldi                    "x = _\n3\r"
3028*7d76303dSAmine Khaldi                    "x = _\r\n3\r"
3029827f6644SAmine Khaldi                    "Sub testsub(arg)\r"
3030827f6644SAmine Khaldi                    "If arg = 1 Then\r\r"
3031827f6644SAmine Khaldi                    "Call reportSuccess()\n\n"
3032827f6644SAmine Khaldi                    "End If\r\n"
3033827f6644SAmine Khaldi                    "End Sub\n\r"
3034827f6644SAmine Khaldi                    "Call testsub(1)");
3035827f6644SAmine Khaldi     CHECK_CALLED(global_success_d);
3036827f6644SAmine Khaldi     CHECK_CALLED(global_success_i);
3037827f6644SAmine Khaldi 
3038c2c66affSColin Finck     run_from_res("lang.vbs");
3039c2c66affSColin Finck     run_from_res("api.vbs");
3040c2c66affSColin Finck     run_from_res("regexp.vbs");
3041c2c66affSColin Finck     run_from_res("error.vbs");
3042c2c66affSColin Finck 
3043c2c66affSColin Finck     test_procedures();
3044c2c66affSColin Finck     test_gc();
3045c2c66affSColin Finck     test_msgbox();
3046*7d76303dSAmine Khaldi     test_isexpression();
3047*7d76303dSAmine Khaldi     test_parse_errors();
3048c78e8736SAmine Khaldi     test_parse_context();
3049*7d76303dSAmine Khaldi     test_callbacks();
3050c2c66affSColin Finck }
3051c2c66affSColin Finck 
check_vbscript(void)3052c2c66affSColin Finck static BOOL check_vbscript(void)
3053c2c66affSColin Finck {
3054c2c66affSColin Finck     IRegExp2 *regexp;
3055c2c66affSColin Finck     IUnknown *unk;
3056c2c66affSColin Finck     HRESULT hres;
3057c2c66affSColin Finck 
3058c2c66affSColin Finck     hres = CoCreateInstance(&CLSID_VBScriptRegExp, NULL,
3059c2c66affSColin Finck             CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3060c2c66affSColin Finck             &IID_IUnknown, (void**)&unk);
3061c2c66affSColin Finck     if(hres == REGDB_E_CLASSNOTREG)
3062c2c66affSColin Finck         return FALSE;
3063c2c66affSColin Finck     ok(hres == S_OK, "CoCreateInstance(CLSID_VBScriptRegExp) failed: %x\n", hres);
3064c2c66affSColin Finck 
3065c2c66affSColin Finck     hres = IUnknown_QueryInterface(unk, &IID_IRegExp2, (void**)&regexp);
3066c2c66affSColin Finck     if(SUCCEEDED(hres))
3067c2c66affSColin Finck         IRegExp2_Release(regexp);
3068c2c66affSColin Finck     IUnknown_Release(unk);
3069c2c66affSColin Finck 
3070c2c66affSColin Finck     return hres == S_OK;
3071c2c66affSColin Finck }
3072c2c66affSColin Finck 
START_TEST(run)3073c2c66affSColin Finck START_TEST(run)
3074c2c66affSColin Finck {
3075c2c66affSColin Finck     int argc;
3076c2c66affSColin Finck     char **argv;
3077c2c66affSColin Finck 
3078942c4265SAmine Khaldi     detect_locale();
3079c2c66affSColin Finck     if(!is_english)
3080c2c66affSColin Finck         skip("Skipping some tests in non-English locale\n");
3081c2c66affSColin Finck 
3082c2c66affSColin Finck     argc = winetest_get_mainargs(&argv);
3083c2c66affSColin Finck 
3084c2c66affSColin Finck     CoInitialize(NULL);
3085c2c66affSColin Finck 
3086c2c66affSColin Finck     if(!check_vbscript()) {
3087c2c66affSColin Finck         win_skip("Broken engine, probably too old\n");
3088c2c66affSColin Finck     }else if(argc > 2) {
3089c2c66affSColin Finck         allow_ui = TRUE;
3090c2c66affSColin Finck         uic_handling = SCRIPTUICHANDLING_ALLOW;
3091c2c66affSColin Finck         run_from_file(argv[2]);
3092c2c66affSColin Finck     }else {
3093c2c66affSColin Finck         run_tests();
3094c2c66affSColin Finck     }
3095c2c66affSColin Finck 
3096c2c66affSColin Finck     CoUninitialize();
3097c2c66affSColin Finck }
3098