diff --git a/rostests/winetests/jscript/api.js b/rostests/winetests/jscript/api.js index ad4822c580e..15b4b574939 100644 --- a/rostests/winetests/jscript/api.js +++ b/rostests/winetests/jscript/api.js @@ -60,6 +60,22 @@ ok(tmp === "abc", "encodeURI('abc') = " + tmp); tmp = "" + new Object(); ok(tmp === "[object Object]", "'' + new Object() = " + tmp); +(tmp = new Array).f = Object.prototype.toString; +ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f()); +(tmp = new Boolean).f = Object.prototype.toString; +ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f()); +(tmp = new Date).f = Object.prototype.toString; +ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f()); +(tmp = function() {}).f = Object.prototype.toString; +ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f()); +Math.f = Object.prototype.toString; +ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f()); +(tmp = new Number).f = Object.prototype.toString; +ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f()); +(tmp = new RegExp("")).f = Object.prototype.toString; +ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f()); +(tmp = new String).f = Object.prototype.toString; +ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f()); ok("".length === 0, "\"\".length = " + "".length); ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length); @@ -269,6 +285,19 @@ ok(tmp === "TEST", "''.toUpperCase() = " + tmp); tmp = "tEsT".toUpperCase(3); ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp); +tmp = "".anchor(); +ok(tmp === "", "''.anchor() = " + tmp); +tmp = "".anchor(3); +ok(tmp === "", "''.anchor(3) = " + tmp); +tmp = "".anchor("red"); +ok(tmp === "", "''.anchor('red') = " + tmp); +tmp = "test".anchor(); +ok(tmp === "test", "'test'.anchor() = " + tmp); +tmp = "test".anchor(3); +ok(tmp === "test", "'test'.anchor(3) = " + tmp); +tmp = "test".anchor("green"); +ok(tmp === "test", "'test'.anchor('green') = " + tmp); + tmp = "".big(); ok(tmp === "", "''.big() = " + tmp); tmp = "".big(3); @@ -305,6 +334,35 @@ ok(tmp === "test", "'test'.fixed() = " + tmp); tmp = "test".fixed(3); ok(tmp === "test", "'test'.fixed(3) = " + tmp); +tmp = "".fontcolor(); +ok(tmp === "", "''.fontcolor() = " + tmp); +tmp = "".fontcolor(3); +ok(tmp === "", "''.fontcolor(3) = " + tmp); +tmp = "".fontcolor("red"); +ok(tmp === "", "''.fontcolor('red') = " + tmp); +tmp = "test".fontcolor(); +ok(tmp === "test", "'test'.fontcolor() = " + tmp); +tmp = "test".fontcolor(3); +ok(tmp === "test", "'test'.fontcolor(3) = " + tmp); +tmp = "test".fontcolor("green"); +ok(tmp === "test", "'test'.fontcolor('green') = " + tmp); + +tmp = "".fontsize(); +ok(tmp === "", "''.fontsize() = " + tmp); +tmp = "".fontsize(3); +ok(tmp === "", "''.fontsize(3) = " + tmp); +tmp = "".fontsize("red"); +ok(tmp === "", "''.fontsize('red') = " + tmp); +tmp = "test".fontsize(); +ok(tmp === "test", "'test'.fontsize() = " + tmp); +tmp = "test".fontsize(3); +ok(tmp === "test", "'test'.fontsize(3) = " + tmp); +tmp = "test".fontsize("green"); +ok(tmp === "test", "'test'.fontsize('green') = " + tmp); + +tmp = ("".fontcolor()).fontsize(); +ok(tmp === "", "(''.fontcolor()).fontsize() = " + tmp); + tmp = "".italics(); ok(tmp === "", "''.italics() = " + tmp); tmp = "".italics(3); @@ -314,6 +372,19 @@ ok(tmp === "test", "'test'.italics() = " + tmp); tmp = "test".italics(3); ok(tmp === "test", "'test'.italics(3) = " + tmp); +tmp = "".link(); +ok(tmp === "", "''.link() = " + tmp); +tmp = "".link(3); +ok(tmp === "", "''.link(3) = " + tmp); +tmp = "".link("red"); +ok(tmp === "", "''.link('red') = " + tmp); +tmp = "test".link(); +ok(tmp === "test", "'test'.link() = " + tmp); +tmp = "test".link(3); +ok(tmp === "test", "'test'.link(3) = " + tmp); +tmp = "test".link("green"); +ok(tmp === "test", "'test'.link('green') = " + tmp); + tmp = "".small(); ok(tmp === "", "''.small() = " + tmp); tmp = "".small(3); @@ -350,6 +421,13 @@ ok(tmp === "test", "'test'.sup() = " + tmp); tmp = "test".sup(3); ok(tmp === "test", "'test'.sup(3) = " + tmp); +ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode()); +ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67)); +ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA", + "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65)); +ok(String.fromCharCode(65, NaN, undefined).length === 3, + "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length); + var arr = new Array(); ok(typeof(arr) === "object", "arr () is not object"); ok((arr.length === 0), "arr.length is not 0"); @@ -439,6 +517,19 @@ ok(arr.sort() === arr, "arr.sort() !== arr"); for(var i=0; i < arr.length; i++) ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]); +arr = ["1", "2", "3"]; +arr.length = 1; +ok(arr.length === 1, "arr.length = " + arr.length); +arr.length = 3; +ok(arr.length === 3, "arr.length = " + arr.length); +ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString()); + +arr = Array("a","b","c"); +ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString()); + +ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf"); +ok(arr === arr.valueOf(), "arr !== arr.valueOf"); + var num = new Number(6); arr = [0,1,2]; tmp = arr.concat(3, [4,5], num); @@ -456,6 +547,23 @@ tmp = arr.concat([2]); ok(tmp.length === 3, "tmp.length = " + tmp.length); ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]); +arr = [1,false,'a',null,undefined,'a']; +ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6)); +ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length); +ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice()); +ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc")); +ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8)); +ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length); +ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1)); +ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2)); +ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1)); +tmp = arr.slice(0,6); +for(var i=0; i < arr.length; i++) + ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]); +arr[12] = 2; +ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString()); +ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length); + var num = new Number(2); ok(num.toString() === "2", "num(2).toString !== 2"); var num = new Number(); @@ -474,6 +582,61 @@ ok(tmp === 0, "(new Number()).valueOf = " + tmp); tmp = Number.prototype.valueOf(); ok(tmp === 0, "Number.prototype.valueOf = " + tmp); +function equals(val, base) { + var i; + var num = 0; + var str = val.toString(base); + + for(i=0; ival-val/1000 && num= 4"); + tmp++; +} while(tmp < 4) +ok(tmp === 4, "tmp !== 4") + tmp = 0; while(tmp < 4) { tmp++; @@ -875,4 +882,20 @@ function testEmbededFunctions() { testEmbededFunctions(); +date = new Date(); +date.toString = function() { return "toString"; } +ok(""+date === "toString", "''+date = " + date); +date.toString = function() { return this; } +ok(""+date === ""+date.valueOf(), "''+date = " + date); + +str = new String("test"); +str.valueOf = function() { return "valueOf"; } +ok(""+str === "valueOf", "''+str = " + str); +str.valueOf = function() { return new Date(); } +ok(""+str === "test", "''+str = " + str); + +ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})()); + +ok(createNullBSTR() === '', "createNullBSTR() !== ''"); + reportSuccess(); diff --git a/rostests/winetests/jscript/regexp.js b/rostests/winetests/jscript/regexp.js index 68091019f2b..3e4db68c4af 100644 --- a/rostests/winetests/jscript/regexp.js +++ b/rostests/winetests/jscript/regexp.js @@ -31,7 +31,7 @@ ok(m["0"] === "ab", "m[0] is not \"ab\""); m = "abcabc".match(/ab/g); ok(typeof(m) === "object", "typeof m is not object"); -ok(m.length === 2, "m.length is not 1"); +ok(m.length === 2, "m.length is not 2"); ok(m["0"] === "ab", "m[0] is not \"ab\""); ok(m["1"] === "ab", "m[1] is not \"ab\""); @@ -41,7 +41,7 @@ ok(m === null, "m is not null"); m = "abcabc".match(/Ab/gi); ok(typeof(m) === "object", "typeof m is not object"); -ok(m.length === 2, "m.length is not 1"); +ok(m.length === 2, "m.length is not 2"); ok(m["0"] === "ab", "m[0] is not \"ab\""); ok(m["1"] === "ab", "m[1] is not \"ab\""); @@ -64,22 +64,30 @@ ok(m["0"] === "ab", "m[0] is not \"ab\""); m = "abcabc".match(new RegExp("ab","g")); ok(typeof(m) === "object", "typeof m is not object"); -ok(m.length === 2, "m.length is not 1"); +ok(m.length === 2, "m.length is not 2"); ok(m["0"] === "ab", "m[0] is not \"ab\""); ok(m["1"] === "ab", "m[1] is not \"ab\""); m = "abcabc".match(new RegExp(/ab/g)); ok(typeof(m) === "object", "typeof m is not object"); -ok(m.length === 2, "m.length is not 1"); +ok(m.length === 2, "m.length is not 2"); ok(m["0"] === "ab", "m[0] is not \"ab\""); ok(m["1"] === "ab", "m[1] is not \"ab\""); m = "abcabc".match(new RegExp("ab","g", "test")); ok(typeof(m) === "object", "typeof m is not object"); -ok(m.length === 2, "m.length is not 1"); +ok(m.length === 2, "m.length is not 2"); ok(m["0"] === "ab", "m[0] is not \"ab\""); ok(m["1"] === "ab", "m[1] is not \"ab\""); +m = "abcabcg".match("ab", "g"); +ok(typeof(m) === "object", "typeof m is not object"); +ok(m.length === 1, "m.length is not 1"); +ok(m["0"] === "ab", "m[0] is not \"ab\""); + +m = "abcabc".match(); +ok(m === null, "m is not null"); + r = "- [test] -".replace(/\[([^\[]+)\]/g, "success"); ok(r === "- success -", "r = " + r + " expected '- success -'"); diff --git a/rostests/winetests/jscript/run.c b/rostests/winetests/jscript/run.c index a1fe3b6daeb..ffbbde347e1 100644 --- a/rostests/winetests/jscript/run.c +++ b/rostests/winetests/jscript/run.c @@ -73,6 +73,7 @@ DEFINE_EXPECT(GetItemInfo_testVal); #define DISPID_GLOBAL_OK 0x1004 #define DISPID_GLOBAL_GETVT 0x1005 #define DISPID_GLOBAL_TESTOBJ 0x1006 +#define DISPID_GLOBAL_NULL_BSTR 0x1007 static const WCHAR testW[] = {'t','e','s','t',0}; static const CHAR testA[] = "test"; @@ -283,6 +284,10 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD *pid = DISPID_GLOBAL_TESTOBJ; return S_OK; } + if(!strcmp_wa(bstrName, "createNullBSTR")) { + *pid = DISPID_GLOBAL_NULL_BSTR; + return S_OK; + } if(strict_dispid_check) ok(0, "unexpected call %s\n", debugstr_w(bstrName)); @@ -429,6 +434,13 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, V_VT(pvarRes) = VT_DISPATCH; V_DISPATCH(pvarRes) = (IDispatch*)&testObj; return S_OK; + + case DISPID_GLOBAL_NULL_BSTR: + if(pvarRes) { + V_VT(pvarRes) = VT_BSTR; + V_BSTR(pvarRes) = NULL; + } + return S_OK; } ok(0, "unexpected call %x\n", id);