From 17ceb90b30f14fba20c8205870f2a2f89f7a1e6b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sun, 21 Sep 2008 15:44:29 +0200 Subject: [PATCH] jscript: Added String function implementation. --- dlls/jscript/string.c | 19 +++++++++++++++++++ dlls/jscript/tests/api.js | 11 +++++++++++ 2 files changed, 30 insertions(+) diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 9da1bfb9db2..d4f58cd11d4 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -772,7 +772,26 @@ static HRESULT StringConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DIS { HRESULT hres; + TRACE("\n"); + switch(flags) { + case INVOKE_FUNC: { + BSTR str; + + if(arg_cnt(dp)) { + hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &str); + if(FAILED(hres)) + return hres; + }else { + str = SysAllocStringLen(NULL, 0); + if(!str) + return E_OUTOFMEMORY; + } + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = str; + break; + } case DISPATCH_CONSTRUCT: { DispatchEx *ret; diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index cea936dc2c1..04515e3c78c 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -69,6 +69,17 @@ ok(str.toString() === "test", "str.toString() = " + str.toString()); tmp = "value " + str; ok(tmp === "value test", "'value ' + str = " + tmp); +tmp = String(); +ok(tmp === "", "String() = " + tmp); +tmp = String(false); +ok(tmp === "false", "String(false) = " + tmp); +tmp = String(null); +ok(tmp === "null", "String(null) = " + tmp); +tmp = String("test"); +ok(tmp === "test", "String('test') = " + tmp); +tmp = String("test", "abc"); +ok(tmp === "test", "String('test','abc') = " + tmp); + tmp = "abc".charAt(0); ok(tmp === "a", "'abc',charAt(0) = " + tmp); tmp = "abc".charAt(1); -- 2.11.4.GIT