2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 ok(true, "true is not true?");
22 ok(!false, "!false is not true");
23 ok(!undefined, "!undefined is not true");
24 ok(!null, "!null is not true");
25 ok(!0, "!0 is not true");
26 ok(!0.0, "!0.0 is not true");
28 ok(1 === 1, "1 === 1 is false");
29 ok(!(1 === 2), "!(1 === 2) is false");
30 ok(1.0 === 1, "1.0 === 1 is false");
31 ok("abc" === "abc", "\"abc\" === \"abc\" is false");
32 ok(true === true, "true === true is false");
33 ok(null === null, "null === null is false");
34 ok(undefined === undefined, "undefined === undefined is false");
35 ok(!(undefined === null), "!(undefined === null) is false");
37 ok(1 !== 2, "1 !== 2 is false");
38 ok(null !== undefined, "null !== undefined is false");
41 ok(trueVar, "trueVar is not true");
43 ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
45 function testFunc1(x, y) {
46 ok(this !== undefined, "this is undefined");
47 ok(x === true, "x is not 1");
48 ok(y === "test", "y is not \"test\"");
49 ok(arguments.length === 2, "arguments.length is not 2");
50 ok(arguments["0"] === true, "arguments[0] is not true");
51 ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
56 ok(testFunc1.length === 2, "testFunc1.length is not 2");
58 ok(Object.prototype !== undefined, "Object.prototype is undefined");
59 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
60 ok(String.prototype !== undefined, "String.prototype is undefined");
61 ok(Array.prototype !== undefined, "Array.prototype is undefined");
62 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
63 ok(Number.prototype !== undefined, "Number.prototype is undefined");
64 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
65 ok(Math !== undefined, "Math is undefined");
66 ok(Math.prototype === undefined, "Math.prototype is not undefined");
68 ok(typeof(0) === "number", "typeof(0) is not number");
69 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
70 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
71 ok(typeof("") === "string", "typeof(\"\") is not string");
72 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
73 ok(typeof(null) === "object", "typeof(null) is not object");
74 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
75 ok(typeof(Math) === "object", "typeof(Math) is not object");
76 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
77 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
78 ok(typeof(String) === "function", "typeof(String) is not function");
79 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
80 ok(typeof(this) === "object", "typeof(this) is not object");
82 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
84 var obj1 = new Object();
85 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
87 obj1.func = function () {
88 ok(this === obj1, "this is not obj1");
89 ok(this.test === true, "this.test is not true");
90 ok(arguments.length === 1, "arguments.length is not 1");
91 ok(arguments["0"] === true, "arguments[0] is not true");
96 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
98 function testConstr1() {
101 ok(this !== undefined, "this is undefined");
102 ok(arguments.length === 1, "arguments.length is not 1");
103 ok(arguments["0"] === true, "arguments[0] is not 1");
108 testConstr1.prototype.pvar = 1;
110 var obj2 = new testConstr1(true);
111 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
112 ok(obj2.pvar === 1, "obj2.pvar is not 1");
114 testConstr1.prototype.pvar = 2;
115 ok(obj2.pvar === 2, "obj2.pvar is not 2");
118 testConstr1.prototype.pvar = 1;
119 ok(obj2.pvar === 3, "obj2.pvar is not 3");
125 ok(false, "else evaluated");
126 ok(tmp === 1, "tmp !== 1, if not evaluated?");
130 ok(false, "if evaluated");
133 ok(tmp === 1, "tmp !== 1, if not evaluated?");
136 ok(false, "if(false) evaluated");
141 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
143 var obj3 = { prop1: 1, prop2: typeof(false) };
144 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
145 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");