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

jscript: Treat no argument as "undefined" in RegExp.test.

parent 0acb7fb1
......@@ -101,6 +101,7 @@ static const WCHAR leftContextW[] =
static const WCHAR rightContextW[] =
{'r','i','g','h','t','C','o','n','t','e','x','t',0};
static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
static const WCHAR emptyW[] = {0};
/* FIXME: Better error handling */
......@@ -3717,12 +3718,24 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
match_result_t match;
VARIANT undef_var;
VARIANT_BOOL b;
DWORD argc;
HRESULT hres;
TRACE("\n");
hres = run_exec(ctx, jsthis, arg_cnt(dp) ? get_arg(dp,0) : NULL, ei, NULL, &match, NULL, NULL, &b);
argc = arg_cnt(dp);
if(!argc) {
V_VT(&undef_var) = VT_BSTR;
V_BSTR(&undef_var) = SysAllocString(undefinedW);
if(!V_BSTR(&undef_var))
return E_OUTOFMEMORY;
}
hres = run_exec(ctx, jsthis, argc ? get_arg(dp,0) : &undef_var, ei, NULL, &match, NULL, NULL, &b);
if(!argc)
SysFreeString(V_BSTR(&undef_var));
if(FAILED(hres))
return hres;
......
......@@ -96,6 +96,12 @@ ok(m[1] === "test", "m[1] = " + m[1]);
b = /a*/.test();
ok(b === true, "/a*/.test() returned " + b);
b = /f/.test();
ok(b === true, "/f/.test() returned " + b);
b = /abc/.test();
ok(b === false, "/abc/.test() returned " + b);
m = "abcabc".match(re = /ca/);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1");
......
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