Commit b6089835 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added infrastructure for test scripts.

parent a16f2053
......@@ -9,6 +9,8 @@ CTESTS = \
jscript.c \
run.c
RC_SRCS = rsrc.rc
@MAKE_TEST_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
ok(true, "true is not true?");
reportSuccess();
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* @makedep: lang.js */
lang.js 40 "lang.js"
......@@ -67,9 +67,14 @@ DEFINE_EXPECT(global_success_i);
#define DISPID_GLOBAL_TESTPROPGET 0x1000
#define DISPID_GLOBAL_TESTPROPPUT 0x1001
#define DISPID_GLOBAL_REPORTSUCCESS 0x1002
#define DISPID_GLOBAL_TRACE 0x1003
#define DISPID_GLOBAL_OK 0x1004
static const WCHAR testW[] = {'t','e','s','t',0};
static BOOL strict_dispid_check;
static const char *test_name = "(null)";
static const char *debugstr_w(LPCWSTR str)
{
static char buf[1024];
......@@ -191,6 +196,16 @@ static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown
static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
{
if(!strcmp_wa(bstrName, "ok")) {
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
*pid = DISPID_GLOBAL_OK;
return S_OK;
}
if(!strcmp_wa(bstrName, "trace")) {
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
*pid = DISPID_GLOBAL_TRACE;
return S_OK;
}
if(!strcmp_wa(bstrName, "reportSuccess")) {
CHECK_EXPECT(global_success_d);
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
......@@ -210,6 +225,7 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
return S_OK;
}
if(strict_dispid_check)
ok(0, "unexpected call %s\n", debugstr_w(bstrName));
return DISP_E_UNKNOWNNAME;
}
......@@ -218,6 +234,38 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{
switch(id) {
case DISPID_GLOBAL_OK:
ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
ok(pdp != NULL, "pdp == NULL\n");
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
ok(!pvarRes, "pvarRes != NULL\n");
ok(pei != NULL, "pei == NULL\n");
ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp->rgvarg));
ok(V_BOOL(pdp->rgvarg+1), "%s: %s\n", test_name, debugstr_w(V_BSTR(pdp->rgvarg)));
return S_OK;
case DISPID_GLOBAL_TRACE:
ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
ok(pdp != NULL, "pdp == NULL\n");
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
ok(!pvarRes, "pvarRes != NULL\n");
ok(pei != NULL, "pei == NULL\n");
ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
if(V_VT(pdp->rgvarg) == VT_BSTR)
trace("%s: %s\n", test_name, debugstr_w(V_BSTR(pdp->rgvarg)));
return S_OK;
case DISPID_GLOBAL_REPORTSUCCESS:
CHECK_EXPECT(global_success_i);
......@@ -433,8 +481,39 @@ static void parse_script_a(const char *src)
SysFreeString(tmp);
}
static void run_from_res(const char *name)
{
const char *data;
DWORD size, len;
BSTR str;
HRSRC src;
strict_dispid_check = FALSE;
test_name = name;
src = FindResourceA(NULL, name, (LPCSTR)40);
ok(src != NULL, "Could not find resource %s\n", name);
size = SizeofResource(NULL, src);
data = LoadResource(NULL, src);
len = MultiByteToWideChar(CP_ACP, 0, data, size, NULL, 0);
str = SysAllocStringLen(NULL, len-1);
len = MultiByteToWideChar(CP_ACP, 0, data, size, str, len);
SET_EXPECT(global_success_d);
SET_EXPECT(global_success_i);
parse_script(str);
CHECK_CALLED(global_success_d);
CHECK_CALLED(global_success_i);
SysFreeString(str);
}
static void run_tests(void)
{
strict_dispid_check = TRUE;
parse_script_a("");
parse_script_a("/* empty */ ;");
......@@ -455,6 +534,8 @@ static void run_tests(void)
parse_script_a("reportSuccess();");
CHECK_CALLED(global_success_d);
CHECK_CALLED(global_success_i);
run_from_res("lang.js");
}
START_TEST(run)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment