jscript: Added String function implementation.

This commit is contained in:
Jacek Caban 2008-09-21 15:44:29 +02:00 committed by Alexandre Julliard
parent 6751644835
commit 17ceb90b30
2 changed files with 30 additions and 0 deletions

View File

@ -772,7 +772,26 @@ static HRESULT StringConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DIS
{ {
HRESULT hres; HRESULT hres;
TRACE("\n");
switch(flags) { 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: { case DISPATCH_CONSTRUCT: {
DispatchEx *ret; DispatchEx *ret;

View File

@ -69,6 +69,17 @@ ok(str.toString() === "test", "str.toString() = " + str.toString());
tmp = "value " + str; tmp = "value " + str;
ok(tmp === "value test", "'value ' + str = " + tmp); 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); tmp = "abc".charAt(0);
ok(tmp === "a", "'abc',charAt(0) = " + tmp); ok(tmp === "a", "'abc',charAt(0) = " + tmp);
tmp = "abc".charAt(1); tmp = "abc".charAt(1);