From 3909672f59f25d288dc286e5d12d5f04d4ae4393 Mon Sep 17 00:00:00 2001 From: Andrew Nguyen Date: Sun, 23 Nov 2008 16:36:50 -0600 Subject: [PATCH] jscript: Implement the String.toUpperCase() method. --- dlls/jscript/string.c | 30 ++++++++++++++++++++++++++++-- dlls/jscript/tests/api.js | 11 +++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 391f3706cce..5c074e8bf69 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -1102,8 +1102,34 @@ static HRESULT String_toLowerCase(DispatchEx *dispex, LCID lcid, WORD flags, DIS static HRESULT String_toUpperCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + StringInstance *string; + const WCHAR* str; + DWORD length; + BSTR bstr; + + TRACE("\n"); + + if(is_class(dispex, JSCLASS_STRING)) { + string = (StringInstance*)dispex; + + length = string->length; + str = string->str; + }else { + FIXME("not string this not supported\n"); + return E_NOTIMPL; + } + + if(retv) { + bstr = SysAllocStringLen(str, length); + if (!bstr) + return E_OUTOFMEMORY; + + struprW(bstr); + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = bstr; + } + return S_OK; } static HRESULT String_toLocaleLowerCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index fc913eb1089..4f843ec7ad0 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -258,6 +258,17 @@ ok(tmp === "test", "''.toLowerCase() = " + tmp); tmp = "tEsT".toLowerCase(3); ok(tmp === "test", "''.toLowerCase(3) = " + tmp); +tmp = "".toUpperCase(); +ok(tmp === "", "''.toUpperCase() = " + tmp); +tmp = "TEST".toUpperCase(); +ok(tmp === "TEST", "''.toUpperCase() = " + tmp); +tmp = "TEST".toUpperCase(3); +ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp); +tmp = "tEsT".toUpperCase(); +ok(tmp === "TEST", "''.toUpperCase() = " + tmp); +tmp = "tEsT".toUpperCase(3); +ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp); + var arr = new Array(); ok(typeof(arr) === "object", "arr () is not object"); ok((arr.length === 0), "arr.length is not 0");