Jacek Caban : jscript: Added RegExp.test implementation.
Alexandre Julliard
julliard at winehq.org
Fri Aug 28 10:17:46 CDT 2009
Module: wine
Branch: master
Commit: 39521de78404146d7dd9795f333f51f076e916e5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=39521de78404146d7dd9795f333f51f076e916e5
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Aug 27 21:34:20 2009 +0200
jscript: Added RegExp.test implementation.
---
dlls/jscript/regexp.c | 17 +++++++++++++++--
dlls/jscript/tests/regexp.js | 20 ++++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c
index 5c473d4..b675008 100644
--- a/dlls/jscript/regexp.c
+++ b/dlls/jscript/regexp.c
@@ -3646,8 +3646,21 @@ static HRESULT RegExp_exec(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
static HRESULT RegExp_test(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ match_result_t match;
+ VARIANT_BOOL b;
+ HRESULT hres;
+
+ TRACE("\n");
+
+ hres = run_exec(dispex, arg_cnt(dp) ? get_arg(dp,0) : NULL, lcid, ei, NULL, &match, NULL, NULL, &b);
+ if(FAILED(hres))
+ return hres;
+
+ if(retv) {
+ V_VT(retv) = VT_BOOL;
+ V_BOOL(retv) = b;
+ }
+ return S_OK;
}
static HRESULT RegExp_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js
index 27c1afb..a839adb 100644
--- a/dlls/jscript/tests/regexp.js
+++ b/dlls/jscript/tests/regexp.js
@@ -71,6 +71,26 @@ m = re.exec();
ok(m === null, "m is not null");
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
+b = re.test(" a ");
+ok(b === true, "re.test(' a ') returned " + b);
+ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
+
+b = re.test(" a ");
+ok(b === false, "re.test(' a ') returned " + b);
+ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
+
+re = /\[([^\[]+)\]/g;
+m = re.exec(" [test] ");
+ok(re.lastIndex === 7, "re.lastIndex = " + re.lastIndex);
+ok(m.index === 1, "m.index = " + m.index);
+ok(m.input === " [test] ", "m.input = " + m.input);
+ok(m.length === 2, "m.length = " + m.length);
+ok(m[0] === "[test]", "m[0] = " + m[0]);
+ok(m[1] === "test", "m[1] = " + m[1]);
+
+b = /a*/.test();
+ok(b === true, "/a*/.test() returned " + b);
+
m = "abcabc".match(/ca/);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1");
More information about the wine-cvs
mailing list