mirror of
https://github.com/reactos/reactos.git
synced 2024-07-02 18:54:25 +00:00
-sync jscript_winetest with wine 1.1.31
svn path=/trunk/; revision=43608
This commit is contained in:
parent
ed2ac13f03
commit
502388c635
|
@ -58,6 +58,32 @@ ok(tmp === "undefined", "encodeURI() = " + tmp);
|
|||
tmp = encodeURI("abc", "test");
|
||||
ok(tmp === "abc", "encodeURI('abc') = " + tmp);
|
||||
|
||||
tmp = escape("abc");
|
||||
ok(tmp === "abc", "escape('abc') = " + tmp);
|
||||
tmp = escape("");
|
||||
ok(tmp === "", "escape('') = " + tmp);
|
||||
tmp = escape("a1b c!d+e@*-_+./,");
|
||||
ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
|
||||
tmp = escape();
|
||||
ok(tmp === "undefined", "escape() = " + tmp);
|
||||
tmp = escape('\u1234\123\xf3');
|
||||
ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
|
||||
|
||||
tmp = unescape("abc");
|
||||
ok(tmp === "abc", "unescape('abc') = " + tmp);
|
||||
tmp = unescape("");
|
||||
ok(tmp === "", "unescape('') = " + tmp);
|
||||
tmp = unescape("%%%");
|
||||
ok(tmp === "%%%", "unescape('%%%') = " + tmp);
|
||||
tmp = unescape();
|
||||
ok(tmp === "undefined", "unescape() = " + tmp);
|
||||
tmp = unescape("%54%65s%u0074");
|
||||
ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
|
||||
|
||||
tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
|
||||
ok(escape(tmp) === "aA1%7E%60%21@%23%24%25%5E%26*%28%29_+%3D-%5D%5B%7B%7D%27%3B%3A/.%2C%3C%3E%3F%7C", "escape('" + tmp + "') = " + escape(tmp));
|
||||
ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
|
||||
|
||||
tmp = "" + new Object();
|
||||
ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
|
||||
(tmp = new Array).f = Object.prototype.toString;
|
||||
|
@ -76,6 +102,23 @@ ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
|
|||
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());
|
||||
tmp = Object.prototype.toString.call(testObj);
|
||||
ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
|
||||
tmp = Object.prototype.toString.call(this);
|
||||
ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
|
||||
(function () { tmp = Object.prototype.toString.call(arguments); })();
|
||||
ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
|
||||
|
||||
ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
|
||||
ok(Object("") instanceof String, "Object('') is not instance of String");
|
||||
ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
|
||||
|
||||
obj = new Object();
|
||||
ok(Object(obj) === obj, "Object(obj) !== obj");
|
||||
|
||||
ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
|
||||
ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
|
||||
ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
|
||||
|
||||
var obj = new Object();
|
||||
obj.toString = function (x) {
|
||||
|
@ -84,6 +127,7 @@ obj.toString = function (x) {
|
|||
};
|
||||
ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
|
||||
ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
|
||||
ok(obj === obj.valueOf(), "obj !== obj.valueOf");
|
||||
|
||||
ok("".length === 0, "\"\".length = " + "".length);
|
||||
ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
|
||||
|
@ -111,6 +155,11 @@ ok(str.toString() === "", "str.toString() = " + str.toString());
|
|||
var str = new String("test", "abc");
|
||||
ok(str.toString() === "test", "str.toString() = " + str.toString());
|
||||
|
||||
var strObj = new Object();
|
||||
strObj.toString = function() { return "abcd" };
|
||||
strObj.substr = String.prototype.substr;
|
||||
strObj.lastIndexOf = String.prototype.lastIndexOf;
|
||||
|
||||
tmp = "value " + str;
|
||||
ok(tmp === "value test", "'value ' + str = " + tmp);
|
||||
|
||||
|
@ -154,6 +203,12 @@ tmp = "abc".charCodeAt(true);
|
|||
ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
|
||||
tmp = "abc".charCodeAt(0,2);
|
||||
ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
|
||||
tmp = "\u49F4".charCodeAt(0);
|
||||
ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
|
||||
tmp = "\052".charCodeAt(0);
|
||||
ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
|
||||
tmp = "\xa2".charCodeAt(0);
|
||||
ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
|
||||
|
||||
tmp = "abcd".substring(1,3);
|
||||
ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
|
||||
|
@ -172,6 +227,25 @@ ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
|
|||
tmp = "abcd".substring();
|
||||
ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
|
||||
|
||||
tmp = "abcd".substr(1,3);
|
||||
ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
|
||||
tmp = "abcd".substr(-1,3);
|
||||
ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
|
||||
tmp = "abcd".substr(1,6);
|
||||
ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
|
||||
tmp = "abcd".substr(2,-1);
|
||||
ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
|
||||
tmp = "abcd".substr(2,0);
|
||||
ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
|
||||
tmp = "abcd".substr(true,"3");
|
||||
ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
|
||||
tmp = "abcd".substr(1,3,2);
|
||||
ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
|
||||
tmp = "abcd".substr();
|
||||
ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
|
||||
tmp = strObj.substr(1,1);
|
||||
ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
|
||||
|
||||
tmp = "abcd".slice(1,3);
|
||||
ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
|
||||
tmp = "abcd".slice(1,-1);
|
||||
|
@ -271,6 +345,25 @@ ok(tmp === 1, "indexOf = " + tmp);
|
|||
tmp = "abcd".indexOf();
|
||||
ok(tmp == -1, "indexOf = " + tmp);
|
||||
|
||||
tmp = "abcd".lastIndexOf("bc",1);
|
||||
ok(tmp === 1, "lastIndexOf = " + tmp);
|
||||
tmp = "abcd".lastIndexOf("bc",2);
|
||||
ok(tmp === 1, "lastIndexOf = " + tmp);
|
||||
tmp = "abcd".lastIndexOf("bc");
|
||||
ok(tmp === 1, "lastIndexOf = " + tmp);
|
||||
tmp = "abcd".lastIndexOf("ac");
|
||||
ok(tmp === -1, "lastIndexOf = " + tmp);
|
||||
tmp = "abcd".lastIndexOf("d",10);
|
||||
ok(tmp === 3, "lastIndexOf = " + tmp);
|
||||
tmp = "abcd".lastIndexOf("bc",0,"test");
|
||||
ok(tmp === -1, "lastIndexOf = " + tmp);
|
||||
tmp = "abcd".lastIndexOf();
|
||||
ok(tmp === -1, "lastIndexOf = " + tmp);
|
||||
tmp = "aaaa".lastIndexOf("a",2);
|
||||
ok(tmp == 2, "lastIndexOf = " + tmp);
|
||||
tmp = strObj.lastIndexOf("b");
|
||||
ok(tmp === 1, "lastIndexOf = " + tmp);
|
||||
|
||||
tmp = "".toLowerCase();
|
||||
ok(tmp === "", "''.toLowerCase() = " + tmp);
|
||||
tmp = "test".toLowerCase();
|
||||
|
@ -469,6 +562,19 @@ ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
|
|||
ok(arr[8] === "b", "arr[8] != 'b'");
|
||||
ok(arr.length === 10, "arr.length != 10");
|
||||
|
||||
var arr = new Object();
|
||||
arr.push = Array.prototype.push;
|
||||
|
||||
arr.length = 6;
|
||||
|
||||
ok(arr.push() === 6, "arr.push() !== 6");
|
||||
ok(arr.push(1) === 7, "arr.push(1) !== 7");
|
||||
ok(arr[6] === 1, "arr[6] != 1");
|
||||
ok(arr.length === 7, "arr.length != 10");
|
||||
ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
|
||||
ok(arr[8] === "b", "arr[8] != 'b'");
|
||||
ok(arr.length === 10, "arr.length != 10");
|
||||
|
||||
arr = [3,4,5];
|
||||
tmp = arr.pop();
|
||||
ok(arr.length === 2, "arr.length = " + arr.length);
|
||||
|
@ -538,6 +644,64 @@ 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");
|
||||
|
||||
arr = [1,2,3];
|
||||
tmp = arr.unshift(0);
|
||||
ok(tmp === undefined, "[1,2,3].unshift(0) returned " +tmp);
|
||||
ok(arr.length === 4, "arr.length = " + arr.length);
|
||||
ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
|
||||
|
||||
arr = new Array(3);
|
||||
arr[0] = 1;
|
||||
arr[2] = 3;
|
||||
tmp = arr.unshift(-1,0);
|
||||
ok(tmp === undefined, "unshift returned " +tmp);
|
||||
ok(arr.length === 5, "arr.length = " + arr.length);
|
||||
ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
|
||||
|
||||
arr = [1,2,3];
|
||||
tmp = arr.unshift();
|
||||
ok(tmp === undefined, "unshift returned " +tmp);
|
||||
ok(arr.length === 3, "arr.length = " + arr.length);
|
||||
ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
|
||||
|
||||
arr = new Object();
|
||||
arr.length = 2;
|
||||
arr[0] = 1;
|
||||
arr[1] = 2;
|
||||
tmp = Array.prototype.unshift.call(arr, 0);
|
||||
ok(tmp === undefined, "unshift returned " +tmp);
|
||||
ok(arr.length === 3, "arr.length = " + arr.length);
|
||||
ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
|
||||
|
||||
arr = [1,2,,4];
|
||||
tmp = arr.shift();
|
||||
ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
|
||||
ok(arr.toString() === "2,,4", "arr = " + arr.toString());
|
||||
|
||||
arr = [];
|
||||
tmp = arr.shift();
|
||||
ok(tmp === undefined, "[].shift() = " + tmp);
|
||||
ok(arr.toString() === "", "arr = " + arr.toString());
|
||||
|
||||
arr = [1,2,,4];
|
||||
tmp = arr.shift(2);
|
||||
ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
|
||||
ok(arr.toString() === "2,,4", "arr = " + arr.toString());
|
||||
|
||||
arr = [1,];
|
||||
tmp = arr.shift();
|
||||
ok(tmp === 1, "[1,].shift() = " + tmp);
|
||||
ok(arr.toString() === "", "arr = " + arr.toString());
|
||||
|
||||
obj = new Object();
|
||||
obj[0] = "test";
|
||||
obj[2] = 3;
|
||||
obj.length = 3;
|
||||
tmp = Array.prototype.shift.call(obj);
|
||||
ok(tmp === "test", "obj.shift() = " + tmp);
|
||||
ok(obj.length == 2, "obj.length = " + obj.length);
|
||||
ok(obj[1] === 3, "obj[1] = " + obj[1]);
|
||||
|
||||
var num = new Number(6);
|
||||
arr = [0,1,2];
|
||||
tmp = arr.concat(3, [4,5], num);
|
||||
|
@ -572,6 +736,87 @@ 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);
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(2,2);
|
||||
ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(2,2,"a");
|
||||
ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(2,2,'a','b','c');
|
||||
ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,];
|
||||
tmp = arr.splice(2,2,'a','b','c');
|
||||
ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,];
|
||||
arr.splice(2,2,'a','b','c');
|
||||
ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(2,2,'a','b');
|
||||
ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(-1,2);
|
||||
ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(-10,3);
|
||||
ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
|
||||
ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(-10,100);
|
||||
ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
|
||||
ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(2,-1);
|
||||
ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice(2);
|
||||
ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
|
||||
|
||||
arr = [1,2,3,4,5];
|
||||
tmp = arr.splice();
|
||||
ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
|
||||
ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
|
||||
|
||||
obj = new Object();
|
||||
obj.length = 3;
|
||||
obj[0] = 1;
|
||||
obj[1] = 2;
|
||||
obj[2] = 3;
|
||||
tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
|
||||
ok(tmp.toString() === "2", "obj.splice returned " + tmp);
|
||||
ok(obj.length === 4, "obj.length = " + obj.length);
|
||||
ok(obj[0] === 1, "obj[0] = " + obj[0]);
|
||||
ok(obj[1] === 'a', "obj[1] = " + obj[1]);
|
||||
ok(obj[2] === 'b', "obj[2] = " + obj[2]);
|
||||
ok(obj[3] === 3, "obj[3] = " + obj[3]);
|
||||
|
||||
obj = new Object();
|
||||
obj.length = 3;
|
||||
obj[0] = 1;
|
||||
obj[1] = 2;
|
||||
obj[2] = 3;
|
||||
tmp = Array.prototype.slice.call(obj, 1, 2);
|
||||
ok(tmp.length === 1, "tmp.length = " + tmp.length);
|
||||
ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
|
||||
|
||||
var num = new Number(2);
|
||||
ok(num.toString() === "2", "num(2).toString !== 2");
|
||||
var num = new Number();
|
||||
|
@ -1102,6 +1347,41 @@ ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return
|
|||
ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
|
||||
"'' + testFuncToString = " + testFuncToString);
|
||||
|
||||
tmp = new Object();
|
||||
|
||||
function callTest(argc) {
|
||||
ok(this === tmp, "this !== tmp\n");
|
||||
ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
|
||||
for(var i=1; i <= argc; i++)
|
||||
ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
|
||||
}
|
||||
|
||||
callTest.call(tmp, 1, 1);
|
||||
callTest.call(tmp, 2, 1, 2);
|
||||
|
||||
callTest.apply(tmp, [1, 1]);
|
||||
callTest.apply(tmp, [2, 1, 2]);
|
||||
(function () { callTest.apply(tmp, arguments); })(2,1,2);
|
||||
|
||||
function callTest2() {
|
||||
ok(this === tmp, "this !== tmp\n");
|
||||
ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
|
||||
}
|
||||
|
||||
callTest2.call(tmp);
|
||||
callTest2.apply(tmp, []);
|
||||
callTest2.apply(tmp);
|
||||
(function () { callTest2.apply(tmp, arguments); })();
|
||||
|
||||
function callTest3() {
|
||||
ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
|
||||
}
|
||||
|
||||
callTest3.call();
|
||||
|
||||
tmp = Number.prototype.toString.call(3);
|
||||
ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
|
||||
|
||||
var date = new Date();
|
||||
|
||||
date = new Date(100);
|
||||
|
@ -1255,6 +1535,17 @@ ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
|
|||
Math.SQRT1_2 = "test";
|
||||
ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
|
||||
|
||||
ok(isNaN.toString() === "\nfunction isNaN() {\n [native code]\n}\n",
|
||||
"isNaN.toString = '" + isNaN.toString() + "'");
|
||||
ok(Array.toString() === "\nfunction Array() {\n [native code]\n}\n",
|
||||
"isNaN.toString = '" + Array.toString() + "'");
|
||||
ok(Function.toString() === "\nfunction Function() {\n [native code]\n}\n",
|
||||
"isNaN.toString = '" + Function.toString() + "'");
|
||||
ok(Function.prototype.toString() === "\nfunction prototype() {\n [native code]\n}\n",
|
||||
"isNaN.toString = '" + Function.prototype.toString() + "'");
|
||||
ok("".substr.toString() === "\nfunction substr() {\n [native code]\n}\n",
|
||||
"''.substr.toString = '" + "".substr.toString() + "'");
|
||||
|
||||
var bool = new Boolean();
|
||||
ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
|
||||
var bool = new Boolean("false");
|
||||
|
@ -1262,6 +1553,9 @@ ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
|
|||
ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
|
||||
ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
|
||||
|
||||
ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
|
||||
ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
|
||||
|
||||
ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
|
||||
ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
|
||||
ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
|
||||
|
@ -1352,8 +1646,94 @@ exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
|
|||
exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
|
||||
exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
|
||||
exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
|
||||
exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281);
|
||||
exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271);
|
||||
|
||||
function testThisExcept(func, number) {
|
||||
exception_test(function() {func.call(new Object())}, "TypeError", number);
|
||||
}
|
||||
|
||||
function testBoolThis(func) {
|
||||
testThisExcept(Boolean.prototype[func], -2146823278);
|
||||
}
|
||||
|
||||
testBoolThis("toString");
|
||||
testBoolThis("valueOf");
|
||||
|
||||
function testDateThis(func) {
|
||||
testThisExcept(Date.prototype[func], -2146823282);
|
||||
}
|
||||
|
||||
testDateThis("getDate");
|
||||
testDateThis("getDay");
|
||||
testDateThis("getFullYear");
|
||||
testDateThis("getHours");
|
||||
testDateThis("getMilliseconds");
|
||||
testDateThis("getMinutes");
|
||||
testDateThis("getMonth");
|
||||
testDateThis("getSeconds");
|
||||
testDateThis("getTime");
|
||||
testDateThis("getTimezoneOffset");
|
||||
testDateThis("getUTCDate");
|
||||
testDateThis("getUTCDay");
|
||||
testDateThis("getUTCFullYear");
|
||||
testDateThis("getUTCHours");
|
||||
testDateThis("getUTCMilliseconds");
|
||||
testDateThis("getUTCMinutes");
|
||||
testDateThis("getUTCMonth");
|
||||
testDateThis("getUTCSeconds");
|
||||
testDateThis("setDate");
|
||||
testDateThis("setFullYear");
|
||||
testDateThis("setHours");
|
||||
testDateThis("setMilliseconds");
|
||||
testDateThis("setMinutes");
|
||||
testDateThis("setMonth");
|
||||
testDateThis("setSeconds");
|
||||
testDateThis("setTime");
|
||||
testDateThis("setUTCDate");
|
||||
testDateThis("setUTCFullYear");
|
||||
testDateThis("setUTCHours");
|
||||
testDateThis("setUTCMilliseconds");
|
||||
testDateThis("setUTCMinutes");
|
||||
testDateThis("setUTCMonth");
|
||||
testDateThis("setUTCSeconds");
|
||||
testDateThis("toDateString");
|
||||
testDateThis("toLocaleDateString");
|
||||
testDateThis("toLocaleString");
|
||||
testDateThis("toLocaleTimeString");
|
||||
testDateThis("toString");
|
||||
testDateThis("toTimeString");
|
||||
testDateThis("toUTCString");
|
||||
testDateThis("valueOf");
|
||||
|
||||
function testArrayThis(func) {
|
||||
testThisExcept(Array.prototype[func], -2146823257);
|
||||
}
|
||||
|
||||
testArrayThis("toString");
|
||||
|
||||
function testFunctionThis(func) {
|
||||
testThisExcept(Function.prototype[func], -2146823286);
|
||||
}
|
||||
|
||||
testFunctionThis("toString");
|
||||
testFunctionThis("call");
|
||||
testFunctionThis("apply");
|
||||
|
||||
function testArrayHostThis(func) {
|
||||
exception_test(function() { Array.prototype[func].call(testObj); }, "TypeError", -2146823274);
|
||||
}
|
||||
|
||||
testArrayHostThis("push");
|
||||
testArrayHostThis("shift");
|
||||
testArrayHostThis("slice");
|
||||
testArrayHostThis("splice");
|
||||
testArrayHostThis("unshift");
|
||||
|
||||
function testObjectInherit(obj, constr, ts, tls, vo) {
|
||||
ok(obj instanceof Object, "obj is not instance of Object");
|
||||
ok(obj instanceof constr, "obj is not instance of its constructor");
|
||||
|
||||
function testObjectInherit(obj, ts, tls, vo) {
|
||||
ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
|
||||
"obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
|
||||
ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
|
||||
|
@ -1386,15 +1766,17 @@ function testObjectInherit(obj, ts, tls, vo) {
|
|||
}
|
||||
|
||||
Object.prototype._test = "test";
|
||||
testObjectInherit(new String("test"), false, true, false);
|
||||
testObjectInherit(/test/g, false, true, true);
|
||||
testObjectInherit(new Number(1), false, false, false);
|
||||
testObjectInherit(new Date(), false, false, false);
|
||||
testObjectInherit(new Boolean(true), false, true, false);
|
||||
testObjectInherit(new Array(), false, false, true);
|
||||
testObjectInherit(new Error(), false, true, true);
|
||||
testObjectInherit(testObjectInherit, false, true, true);
|
||||
testObjectInherit(Math, true, true, true);
|
||||
testObjectInherit(new String("test"), String, false, true, false);
|
||||
testObjectInherit(/test/g, RegExp, false, true, true);
|
||||
testObjectInherit(new Number(1), Number, false, false, false);
|
||||
testObjectInherit(new Date(), Date, false, false, false);
|
||||
testObjectInherit(new Boolean(true), Boolean, false, true, false);
|
||||
testObjectInherit(new Array(), Array, false, false, true);
|
||||
testObjectInherit(new Error(), Error, false, true, true);
|
||||
testObjectInherit(testObjectInherit, Function, false, true, true);
|
||||
testObjectInherit(Math, Object, true, true, true);
|
||||
|
||||
(function() { testObjectInherit(arguments, Object, true, true, true); })();
|
||||
|
||||
function testFunctions(obj, arr) {
|
||||
var l;
|
||||
|
@ -1500,6 +1882,7 @@ testFunctions(Date.prototype, [
|
|||
["toString", 0],
|
||||
["toTimeString", 0],
|
||||
["toUTCString", 0],
|
||||
["toGMTString", 0],
|
||||
["valueOf", 0]
|
||||
]);
|
||||
|
||||
|
@ -1552,4 +1935,10 @@ testFunctions(Object.prototype, [
|
|||
["valueOf", 0]
|
||||
]);
|
||||
|
||||
testFunctions(Function.prototype, [
|
||||
["apply", 2],
|
||||
["call", 1],
|
||||
["toString", 0]
|
||||
]);
|
||||
|
||||
reportSuccess();
|
||||
|
|
|
@ -68,6 +68,18 @@ DEFINE_EXPECT(OnStateChange_INITIALIZED);
|
|||
DEFINE_EXPECT(OnEnterScript);
|
||||
DEFINE_EXPECT(OnLeaveScript);
|
||||
|
||||
static BSTR a2bstr(const char *str)
|
||||
{
|
||||
BSTR ret;
|
||||
int len;
|
||||
|
||||
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
||||
ret = SysAllocStringLen(NULL, len-1);
|
||||
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define test_state(s,ss) _test_state(__LINE__,s,ss)
|
||||
static void _test_state(unsigned line, IActiveScript *script, SCRIPTSTATE exstate)
|
||||
{
|
||||
|
@ -195,6 +207,8 @@ static void test_script_dispatch(IActiveScript *script, BOOL initialized)
|
|||
{
|
||||
IDispatchEx *dispex;
|
||||
IDispatch *disp;
|
||||
BSTR str;
|
||||
DISPID id;
|
||||
HRESULT hres;
|
||||
|
||||
disp = (void*)0xdeadbeef;
|
||||
|
@ -214,6 +228,11 @@ static void test_script_dispatch(IActiveScript *script, BOOL initialized)
|
|||
IDispatch_Release(disp);
|
||||
ok(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
|
||||
|
||||
str = a2bstr("ActiveXObject");
|
||||
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
|
||||
SysFreeString(str);
|
||||
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
||||
|
||||
IDispatchEx_Release(dispex);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ ok(undefined === undefined, "undefined === undefined is false");
|
|||
ok(!(undefined === null), "!(undefined === null) is false");
|
||||
ok(1E0 === 1, "1E0 === 1 is false");
|
||||
ok(1000000*1000000 === 1000000000000, "1000000*1000000 === 1000000000000 is false");
|
||||
ok(8.64e15 === 8640000000000000, "8.64e15 !== 8640000000000000"+8.64e15);
|
||||
ok(8.64e15 === 8640000000000000, "8.64e15 !== 8640000000000000");
|
||||
ok(1e2147483648 === Infinity, "1e2147483648 !== Infinity");
|
||||
|
||||
ok(1 !== 2, "1 !== 2 is false");
|
||||
|
@ -63,11 +63,12 @@ ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
|
|||
|
||||
function testFunc1(x, y) {
|
||||
ok(this !== undefined, "this is undefined");
|
||||
ok(x === true, "x is not 1");
|
||||
ok(x === true, "x is not true");
|
||||
ok(y === "test", "y is not \"test\"");
|
||||
ok(arguments.length === 2, "arguments.length is not 2");
|
||||
ok(arguments["0"] === true, "arguments[0] is not true");
|
||||
ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
|
||||
ok(arguments.callee === testFunc1, "arguments.calee !== testFunc1");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -116,6 +117,7 @@ obj1.func = function () {
|
|||
ok(this.test === true, "this.test is not true");
|
||||
ok(arguments.length === 1, "arguments.length is not 1");
|
||||
ok(arguments["0"] === true, "arguments[0] is not true");
|
||||
ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
|
||||
|
||||
return "test";
|
||||
};
|
||||
|
@ -128,6 +130,7 @@ function testConstr1() {
|
|||
ok(this !== undefined, "this is undefined");
|
||||
ok(arguments.length === 1, "arguments.length is not 1");
|
||||
ok(arguments["0"] === true, "arguments[0] is not 1");
|
||||
ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -386,9 +389,9 @@ ok(+"0xff" === 255, "+'0xff' !== 255");
|
|||
ok(+"3e3" === 3000, "+'3e3' !== 3000");
|
||||
|
||||
tmp = new Number(1);
|
||||
ok(+tmp === 1, "ToNumber(new Number(1)) = " + (+tmp));
|
||||
ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
|
||||
tmp = new String("1");
|
||||
ok(+tmp === 1, "ToNumber(new String('1')) = " + (+tmp));
|
||||
ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
|
||||
|
||||
ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
|
||||
ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
|
||||
|
@ -462,7 +465,7 @@ try {
|
|||
ok(state === "", "try: state = " + state);
|
||||
state = "try";
|
||||
}finally {
|
||||
ok(state === "try", "funally: state = " + state);
|
||||
ok(state === "try", "finally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
@ -474,7 +477,7 @@ try {
|
|||
}catch(ex) {
|
||||
ok(false, "unexpected catch");
|
||||
}finally {
|
||||
ok(state === "try", "funally: state = " + state);
|
||||
ok(state === "try", "finally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
@ -501,7 +504,7 @@ try {
|
|||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
ok(state === "catch", "finally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
@ -516,7 +519,7 @@ try {
|
|||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
ok(state === "catch", "finally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
@ -531,7 +534,7 @@ try {
|
|||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
ok(state === "catch", "finally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
@ -550,7 +553,7 @@ try {
|
|||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
ok(state === "catch", "finally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
@ -622,7 +625,7 @@ try {
|
|||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
ok(state === "catch", "finally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
@ -796,6 +799,38 @@ if (true)
|
|||
else
|
||||
ok(true, "else should be associated with nearest if statement");
|
||||
|
||||
function instanceOfTest() {}
|
||||
tmp = new instanceOfTest();
|
||||
|
||||
ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
|
||||
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
||||
ok((tmp instanceof String) === false, "tmp is instance of String");
|
||||
|
||||
instanceOfTest.prototype = new Object();
|
||||
ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
|
||||
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
||||
|
||||
ok((1 instanceof Object) === false, "1 is instance of Object");
|
||||
ok((false instanceof Boolean) === false, "false is instance of Boolean");
|
||||
ok(("" instanceof Object) === false, "'' is instance of Object");
|
||||
|
||||
(function () {
|
||||
ok((arguments instanceof Object) === true, "argument is not instance of Object");
|
||||
ok((arguments instanceof Array) === false, "argument is not instance of Array");
|
||||
ok(arguments.toString() === "[object Object]", "arguments.toString() = " + arguments.toString());
|
||||
})(1,2);
|
||||
|
||||
obj = new String();
|
||||
ok(("length" in obj) === true, "length is not in obj");
|
||||
ok(("isPrototypeOf" in obj) === true, "isPrototypeOf is not in obj");
|
||||
ok(("abc" in obj) === false, "test is in obj");
|
||||
obj.abc = 1;
|
||||
ok(("abc" in obj) === true, "test is not in obj");
|
||||
ok(("1" in obj) === false, "1 is in obj");
|
||||
|
||||
obj = [1,2,3];
|
||||
ok((1 in obj) === true, "1 is not in obj");
|
||||
|
||||
ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
|
||||
ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
|
||||
ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
|
||||
|
@ -805,8 +840,8 @@ ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
|
|||
ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
|
||||
|
||||
ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
|
||||
ok(isFinite(Infinity) === false, "isFinite(Infinity) !== fals");
|
||||
ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== fals");
|
||||
ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");
|
||||
ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");
|
||||
ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
|
||||
ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
|
||||
ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
|
||||
|
@ -896,6 +931,42 @@ ok(""+str === "test", "''+str = " + str);
|
|||
|
||||
ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
|
||||
|
||||
var re = /=(\?|%3F)/g;
|
||||
ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
|
||||
|
||||
ok(createNullBSTR() === '', "createNullBSTR() !== ''");
|
||||
|
||||
ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));
|
||||
ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
|
||||
ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
|
||||
ok(nullDisp !== re, "nullDisp === re");
|
||||
ok(nullDisp === null, "nullDisp === null");
|
||||
ok(nullDisp == null, "nullDisp == null");
|
||||
ok(getVT(true && nullDisp) === "VT_DISPATCH",
|
||||
"getVT(0 && nullDisp) = " + getVT(true && nullDisp));
|
||||
ok(!nullDisp === true, "!nullDisp = " + !nullDisp);
|
||||
ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp));
|
||||
ok(nullDisp != new Object(), "nullDisp == new Object()");
|
||||
ok(new Object() != nullDisp, "new Object() == nullDisp");
|
||||
ok((typeof Object(nullDisp)) === "object", "typeof Object(nullDisp) !== 'object'");
|
||||
tmp = getVT(Object(nullDisp));
|
||||
ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp);
|
||||
tmp = Object(nullDisp).toString();
|
||||
ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp);
|
||||
|
||||
function do_test() {}
|
||||
function nosemicolon() {} nosemicolon();
|
||||
function () {} nosemicolon();
|
||||
|
||||
if(false) {
|
||||
function in_if_false() { return true; } ok(false, "!?");
|
||||
}
|
||||
|
||||
ok(in_if_false(), "in_if_false failed");
|
||||
|
||||
ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist) = " + typeof(doesnotexist));
|
||||
|
||||
(function() { newValue = 1; })();
|
||||
ok(newValue === 1, "newValue = " + newValue);
|
||||
|
||||
reportSuccess();
|
||||
|
|
|
@ -17,7 +17,79 @@
|
|||
*/
|
||||
|
||||
|
||||
var m;
|
||||
var m, re, b;
|
||||
|
||||
re = /a+/;
|
||||
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
|
||||
|
||||
m = re.exec(" aabaaa");
|
||||
ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
|
||||
ok(m.index === 1, "m.index = " + m.index);
|
||||
ok(m.input === " aabaaa", "m.input = " + m.input);
|
||||
ok(m.length === 1, "m.length = " + m.length);
|
||||
ok(m[0] === "aa", "m[0] = " + m[0]);
|
||||
|
||||
m = re.exec(" aabaaa");
|
||||
ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
|
||||
ok(m.index === 1, "m.index = " + m.index);
|
||||
ok(m.input === " aabaaa", "m.input = " + m.input);
|
||||
ok(m.length === 1, "m.length = " + m.length);
|
||||
ok(m[0] === "aa", "m[0] = " + m[0]);
|
||||
|
||||
re = /a+/g;
|
||||
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
|
||||
|
||||
m = re.exec(" aabaaa");
|
||||
ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
|
||||
ok(m.index === 1, "m.index = " + m.index);
|
||||
ok(m.input === " aabaaa", "m.input = " + m.input);
|
||||
ok(m.length === 1, "m.length = " + m.length);
|
||||
ok(m[0] === "aa", "m[0] = " + m[0]);
|
||||
|
||||
m = re.exec(" aabaaa");
|
||||
ok(re.lastIndex === 7, "re.lastIndex = " + re.lastIndex);
|
||||
ok(m.index === 4, "m.index = " + m.index);
|
||||
ok(m.input === " aabaaa", "m.input = " + m.input);
|
||||
ok(m.length === 1, "m.length = " + m.length);
|
||||
ok(m[0] === "aaa", "m[0] = " + m[0]);
|
||||
|
||||
m = re.exec(" aabaaa");
|
||||
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
|
||||
ok(m === null, "m is not null");
|
||||
|
||||
re.exec(" a");
|
||||
ok(re.lastIndex === 16, "re.lastIndex = " + re.lastIndex);
|
||||
|
||||
m = re.exec(" a");
|
||||
ok(m === null, "m is not null");
|
||||
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
|
||||
|
||||
m = re.exec(" a");
|
||||
ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex);
|
||||
|
||||
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");
|
||||
|
@ -208,12 +280,22 @@ ok(r.length === 2, "r.length = " + r.length);
|
|||
ok(r[0] === "1", "r[0] = " + r[0]);
|
||||
ok(r[1] === "2", "r[1] = " + r[1]);
|
||||
|
||||
var re;
|
||||
|
||||
re = /abc[^d]/g;
|
||||
ok(re.source === "abc[^d]", "re.source = '" + re.source + "', expected 'abc[^d]'");
|
||||
|
||||
re = /a\bc[^d]/g;
|
||||
ok(re.source === "a\\bc[^d]", "re.source = '" + re.source + "', expected 'a\\bc[^d]'");
|
||||
|
||||
re = /abc/;
|
||||
ok(re === RegExp(re), "re !== RegExp(re)");
|
||||
|
||||
re = RegExp("abc[^d]", "g");
|
||||
ok(re.source === "abc[^d]", "re.source = '" + re.source + "', expected 'abc[^d]'");
|
||||
|
||||
re = /abc/;
|
||||
ok(re === RegExp(re, undefined), "re !== RegExp(re, undefined)");
|
||||
|
||||
re = /abc/;
|
||||
ok(re === RegExp(re, undefined, 1), "re !== RegExp(re, undefined, 1)");
|
||||
|
||||
reportSuccess();
|
||||
|
|
|
@ -65,6 +65,9 @@ DEFINE_EXPECT(global_success_d);
|
|||
DEFINE_EXPECT(global_success_i);
|
||||
DEFINE_EXPECT(global_notexists_d);
|
||||
DEFINE_EXPECT(testobj_delete);
|
||||
DEFINE_EXPECT(testobj_value);
|
||||
DEFINE_EXPECT(testobj_prop_d);
|
||||
DEFINE_EXPECT(testobj_noprop_d);
|
||||
DEFINE_EXPECT(GetItemInfo_testVal);
|
||||
|
||||
#define DISPID_GLOBAL_TESTPROPGET 0x1000
|
||||
|
@ -75,6 +78,11 @@ DEFINE_EXPECT(GetItemInfo_testVal);
|
|||
#define DISPID_GLOBAL_GETVT 0x1005
|
||||
#define DISPID_GLOBAL_TESTOBJ 0x1006
|
||||
#define DISPID_GLOBAL_NULL_BSTR 0x1007
|
||||
#define DISPID_GLOBAL_NULL_DISP 0x1008
|
||||
#define DISPID_GLOBAL_TESTTHIS 0x1009
|
||||
#define DISPID_GLOBAL_TESTTHIS2 0x100a
|
||||
|
||||
#define DISPID_TESTOBJ_PROP 0x2000
|
||||
|
||||
static const WCHAR testW[] = {'t','e','s','t',0};
|
||||
static const CHAR testA[] = "test";
|
||||
|
@ -83,6 +91,7 @@ static const CHAR test_valA[] = "testVal";
|
|||
|
||||
static BOOL strict_dispid_check;
|
||||
static const char *test_name = "(null)";
|
||||
static IDispatch *script_disp;
|
||||
|
||||
static BSTR a2bstr(const char *str)
|
||||
{
|
||||
|
@ -192,17 +201,48 @@ static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
||||
static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
if(!strcmp_wa(bstrName, "prop")) {
|
||||
CHECK_EXPECT(testobj_prop_d);
|
||||
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
|
||||
*pid = DISPID_TESTOBJ_PROP;
|
||||
return S_OK;
|
||||
}
|
||||
if(!strcmp_wa(bstrName, "noprop")) {
|
||||
CHECK_EXPECT(testobj_noprop_d);
|
||||
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
|
||||
return DISP_E_UNKNOWNNAME;
|
||||
}
|
||||
|
||||
ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
||||
static HRESULT WINAPI testObj_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
||||
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
return E_NOTIMPL;
|
||||
switch(id) {
|
||||
case DISPID_VALUE:
|
||||
CHECK_EXPECT(testobj_value);
|
||||
|
||||
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
||||
ok(pdp != NULL, "pdp == NULL\n");
|
||||
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
||||
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
||||
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
||||
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
||||
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
||||
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
||||
ok(pei != NULL, "pei == NULL\n");
|
||||
|
||||
V_VT(pvarRes) = VT_I4;
|
||||
V_I4(pvarRes) = 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ok(0, "unexpected call %x\n", id);
|
||||
return DISP_E_MEMBERNOTFOUND;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI testObj_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
||||
|
@ -222,8 +262,8 @@ static IDispatchExVtbl testObjVtbl = {
|
|||
DispatchEx_GetTypeInfo,
|
||||
DispatchEx_GetIDsOfNames,
|
||||
DispatchEx_Invoke,
|
||||
DispatchEx_GetDispID,
|
||||
DispatchEx_InvokeEx,
|
||||
testObj_GetDispID,
|
||||
testObj_InvokeEx,
|
||||
testObj_DeleteMemberByName,
|
||||
DispatchEx_DeleteMemberByDispID,
|
||||
DispatchEx_GetMemberProperties,
|
||||
|
@ -278,12 +318,28 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
|
|||
*pid = DISPID_GLOBAL_NULL_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
if(!strcmp_wa(bstrName, "nullDisp")) {
|
||||
*pid = DISPID_GLOBAL_NULL_DISP;
|
||||
return S_OK;
|
||||
}
|
||||
if(!strcmp_wa(bstrName, "notExists")) {
|
||||
CHECK_EXPECT(global_notexists_d);
|
||||
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
|
||||
return DISP_E_UNKNOWNNAME;
|
||||
}
|
||||
|
||||
if(!strcmp_wa(bstrName, "testThis")) {
|
||||
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
|
||||
*pid = DISPID_GLOBAL_TESTTHIS;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(!strcmp_wa(bstrName, "testThis2")) {
|
||||
ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
|
||||
*pid = DISPID_GLOBAL_TESTTHIS2;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(strict_dispid_check)
|
||||
ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
|
||||
return DISP_E_UNKNOWNNAME;
|
||||
|
@ -436,6 +492,50 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
|
|||
V_BSTR(pvarRes) = NULL;
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
case DISPID_GLOBAL_NULL_DISP:
|
||||
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
||||
ok(pdp != NULL, "pdp == NULL\n");
|
||||
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
||||
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
||||
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
||||
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
||||
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
||||
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
||||
ok(pei != NULL, "pei == NULL\n");
|
||||
|
||||
V_VT(pvarRes) = VT_DISPATCH;
|
||||
V_DISPATCH(pvarRes) = NULL;
|
||||
return S_OK;
|
||||
|
||||
case DISPID_GLOBAL_TESTTHIS:
|
||||
ok(pdp != NULL, "pdp == NULL\n");
|
||||
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
||||
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
||||
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
||||
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
||||
ok(pvarRes == NULL, "pvarRes != NULL\n");
|
||||
ok(pei != NULL, "pei == NULL\n");
|
||||
|
||||
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n", V_VT(pdp->rgvarg));
|
||||
ok(V_DISPATCH(pdp->rgvarg) == (IDispatch*)iface, "disp != iface\n");
|
||||
|
||||
return S_OK;
|
||||
|
||||
case DISPID_GLOBAL_TESTTHIS2:
|
||||
ok(pdp != NULL, "pdp == NULL\n");
|
||||
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
||||
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
||||
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
||||
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
||||
ok(pvarRes == NULL, "pvarRes != NULL\n");
|
||||
ok(pei != NULL, "pei == NULL\n");
|
||||
|
||||
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n", V_VT(pdp->rgvarg));
|
||||
ok(V_DISPATCH(pdp->rgvarg) != (IDispatch*)iface, "disp == iface\n");
|
||||
ok(V_DISPATCH(pdp->rgvarg) == script_disp, "disp != script_disp\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ok(0, "unexpected call %x\n", id);
|
||||
|
@ -569,7 +669,7 @@ static IActiveScript *create_script(void)
|
|||
return script;
|
||||
}
|
||||
|
||||
static void parse_script(BSTR script_str)
|
||||
static void parse_script(DWORD flags, BSTR script_str)
|
||||
{
|
||||
IActiveScriptParse *parser;
|
||||
IActiveScript *engine;
|
||||
|
@ -594,15 +694,21 @@ static void parse_script(BSTR script_str)
|
|||
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
||||
|
||||
hres = IActiveScript_AddNamedItem(engine, testW,
|
||||
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
||||
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|flags);
|
||||
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
||||
|
||||
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
||||
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
||||
|
||||
hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
|
||||
ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
|
||||
ok(script_disp != NULL, "script_disp == NULL\n");
|
||||
ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n");
|
||||
|
||||
hres = IActiveScriptParse64_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
||||
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
||||
|
||||
IDispatch_Release(script_disp);
|
||||
IActiveScript_Release(engine);
|
||||
IUnknown_Release(parser);
|
||||
}
|
||||
|
@ -648,13 +754,18 @@ static HRESULT parse_htmlscript(BSTR script_str)
|
|||
return hres;
|
||||
}
|
||||
|
||||
static void parse_script_a(const char *src)
|
||||
static void parse_script_af(DWORD flags, const char *src)
|
||||
{
|
||||
BSTR tmp = a2bstr(src);
|
||||
parse_script(tmp);
|
||||
parse_script(flags, tmp);
|
||||
SysFreeString(tmp);
|
||||
}
|
||||
|
||||
static void parse_script_a(const char *src)
|
||||
{
|
||||
parse_script_af(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||
}
|
||||
|
||||
static HRESULT parse_htmlscript_a(const char *src)
|
||||
{
|
||||
HRESULT hres;
|
||||
|
@ -710,7 +821,7 @@ static void run_from_file(const char *filename)
|
|||
strict_dispid_check = FALSE;
|
||||
|
||||
if(script_str)
|
||||
parse_script(script_str);
|
||||
parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str);
|
||||
|
||||
SysFreeString(script_str);
|
||||
}
|
||||
|
@ -737,7 +848,7 @@ static void run_from_res(const char *name)
|
|||
|
||||
SET_EXPECT(global_success_d);
|
||||
SET_EXPECT(global_success_i);
|
||||
parse_script(str);
|
||||
parse_script(SCRIPTITEM_GLOBALMEMBERS, str);
|
||||
CHECK_CALLED(global_success_d);
|
||||
CHECK_CALLED(global_success_i);
|
||||
|
||||
|
@ -842,6 +953,39 @@ static void run_tests(void)
|
|||
|
||||
parse_script_a("function f() { var testPropGet; }");
|
||||
|
||||
parse_script_a("ok((testObj instanceof Object) === false, 'testObj is instance of Object');");
|
||||
|
||||
SET_EXPECT(testobj_prop_d);
|
||||
parse_script_a("ok(('prop' in testObj) === true, 'prop is not in testObj');");
|
||||
CHECK_CALLED(testobj_prop_d);
|
||||
|
||||
SET_EXPECT(testobj_noprop_d);
|
||||
parse_script_a("ok(('noprop' in testObj) === false, 'noprop is in testObj');");
|
||||
CHECK_CALLED(testobj_noprop_d);
|
||||
|
||||
SET_EXPECT(testobj_value);
|
||||
parse_script_a("ok(String(testObj) === '1', 'wrong testObj value');");
|
||||
CHECK_CALLED(testobj_value);
|
||||
|
||||
SET_EXPECT(testobj_value);
|
||||
parse_script_a("ok(String.prototype.concat.call(testObj, ' OK') === '1 OK', 'wrong concat result');");
|
||||
CHECK_CALLED(testobj_value);
|
||||
|
||||
SET_EXPECT(global_propget_d);
|
||||
SET_EXPECT(global_propget_i);
|
||||
parse_script_a("this.testPropGet;");
|
||||
CHECK_CALLED(global_propget_d);
|
||||
CHECK_CALLED(global_propget_i);
|
||||
|
||||
SET_EXPECT(global_propget_d);
|
||||
SET_EXPECT(global_propget_i);
|
||||
parse_script_a("(function () { this.testPropGet; })();");
|
||||
CHECK_CALLED(global_propget_d);
|
||||
CHECK_CALLED(global_propget_i);
|
||||
|
||||
parse_script_a("testThis(this);");
|
||||
parse_script_a("(function () { testThis(this); })();");
|
||||
|
||||
run_from_res("lang.js");
|
||||
run_from_res("api.js");
|
||||
run_from_res("regexp.js");
|
||||
|
@ -849,6 +993,9 @@ static void run_tests(void)
|
|||
test_isvisible(FALSE);
|
||||
test_isvisible(TRUE);
|
||||
|
||||
parse_script_af(0, "test.testThis2(this);");
|
||||
parse_script_af(0, "(function () { test.testThis2(this); })();");
|
||||
|
||||
hres = parse_htmlscript_a("<!--");
|
||||
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
||||
hres = parse_htmlscript_a("-->");
|
||||
|
|
Loading…
Reference in a new issue