Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tests / auto / qmltest / selftests / tst_compare.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 import QtQuick 2.0
43 import QtTest 1.0
44
45 TestCase {
46     name: "SelfTests_compare"
47
48     function test_primitives_and_constants() {
49         compare(qtest_compareInternal(null, null), true, "null");
50         compare(qtest_compareInternal(null, {}), false, "null");
51         compare(qtest_compareInternal(null, undefined), false, "null");
52         compare(qtest_compareInternal(null, 0), false, "null");
53         compare(qtest_compareInternal(null, false), false, "null");
54         compare(qtest_compareInternal(null, ''), false, "null");
55         compare(qtest_compareInternal(null, []), false, "null");
56
57         compare(qtest_compareInternal(undefined, undefined), true, "undefined");
58         compare(qtest_compareInternal(undefined, null), false, "undefined");
59         compare(qtest_compareInternal(undefined, 0), false, "undefined");
60         compare(qtest_compareInternal(undefined, false), false, "undefined");
61         compare(qtest_compareInternal(undefined, {}), false, "undefined");
62         compare(qtest_compareInternal(undefined, []), false, "undefined");
63         compare(qtest_compareInternal(undefined, ""), false, "undefined");
64
65         // Nan usually doest not equal to Nan using the '==' operator.
66         // Only isNaN() is able to do it.
67         compare(qtest_compareInternal(0/0, 0/0), true, "NaN"); // NaN VS NaN
68         compare(qtest_compareInternal(1/0, 2/0), true, "Infinity"); // Infinity VS Infinity
69         compare(qtest_compareInternal(-1/0, 2/0), false, "-Infinity, Infinity"); // -Infinity VS Infinity
70         compare(qtest_compareInternal(-1/0, -2/0), true, "-Infinity, -Infinity"); // -Infinity VS -Infinity
71         compare(qtest_compareInternal(0/0, 1/0), false, "NaN, Infinity"); // Nan VS Infinity
72         compare(qtest_compareInternal(1/0, 0/0), false, "NaN, Infinity"); // Nan VS Infinity
73         compare(qtest_compareInternal(0/0, null), false, "NaN");
74         compare(qtest_compareInternal(0/0, undefined), false, "NaN");
75         compare(qtest_compareInternal(0/0, 0), false, "NaN");
76         compare(qtest_compareInternal(0/0, false), false, "NaN");
77         //compare(qtest_compareInternal(0/0, function () {}), false, "NaN");       // Do we really need that?
78         compare(qtest_compareInternal(1/0, null), false, "NaN, Infinity");
79         compare(qtest_compareInternal(1/0, undefined), false, "NaN, Infinity");
80         compare(qtest_compareInternal(1/0, 0), false, "NaN, Infinity");
81         compare(qtest_compareInternal(1/0, 1), false, "NaN, Infinity");
82         compare(qtest_compareInternal(1/0, false), false, "NaN, Infinity");
83         compare(qtest_compareInternal(1/0, true), false, "NaN, Infinity");
84         //compare(qtest_compareInternal(1/0, function () {}), false, "NaN");       // Do we really need that?
85
86         compare(qtest_compareInternal(0, 0), true, "number");
87         compare(qtest_compareInternal(0, 1), false, "number");
88         compare(qtest_compareInternal(1, 0), false, "number");
89         compare(qtest_compareInternal(1, 1), true, "number");
90         compare(qtest_compareInternal(1.1, 1.1), true, "number");
91         compare(qtest_compareInternal(0.0000005, 0.0000005), true, "number");
92         compare(qtest_compareInternal(0, ''), false, "number");
93         compare(qtest_compareInternal(0, '0'), false, "number");
94         compare(qtest_compareInternal(1, '1'), false, "number");
95         compare(qtest_compareInternal(0, false), false, "number");
96         compare(qtest_compareInternal(1, true), false, "number");
97
98         compare(qtest_compareInternal(true, true), true, "boolean");
99         compare(qtest_compareInternal(true, false), false, "boolean");
100         compare(qtest_compareInternal(false, true), false, "boolean");
101         compare(qtest_compareInternal(false, 0), false, "boolean");
102         compare(qtest_compareInternal(false, null), false, "boolean");
103         compare(qtest_compareInternal(false, undefined), false, "boolean");
104         compare(qtest_compareInternal(true, 1), false, "boolean");
105         compare(qtest_compareInternal(true, null), false, "boolean");
106         compare(qtest_compareInternal(true, undefined), false, "boolean");
107
108         compare(qtest_compareInternal('', ''), true, "string");
109         compare(qtest_compareInternal('a', 'a'), true, "string");
110         compare(qtest_compareInternal("foobar", "foobar"), true, "string");
111         compare(qtest_compareInternal("foobar", "foo"), false, "string");
112         compare(qtest_compareInternal('', 0), false, "string");
113         compare(qtest_compareInternal('', false), false, "string");
114         compare(qtest_compareInternal('', null), false, "string");
115         compare(qtest_compareInternal('', undefined), false, "string");
116
117         // Short annotation VS new annotation
118         compare(qtest_compareInternal(0, new Number()), true, "short annotation VS new annotation");
119         compare(qtest_compareInternal(new Number(), 0), true, "short annotation VS new annotation");
120         compare(qtest_compareInternal(1, new Number(1)), true, "short annotation VS new annotation");
121         compare(qtest_compareInternal(new Number(1), 1), true, "short annotation VS new annotation");
122         compare(qtest_compareInternal(new Number(0), 1), false, "short annotation VS new annotation");
123         compare(qtest_compareInternal(0, new Number(1)), false, "short annotation VS new annotation");
124
125         compare(qtest_compareInternal(new String(), ""), true, "short annotation VS new annotation");
126         compare(qtest_compareInternal("", new String()), true, "short annotation VS new annotation");
127         compare(qtest_compareInternal(new String("My String"), "My String"), true, "short annotation VS new annotation");
128         compare(qtest_compareInternal("My String", new String("My String")), true, "short annotation VS new annotation");
129         compare(qtest_compareInternal("Bad String", new String("My String")), false, "short annotation VS new annotation");
130         compare(qtest_compareInternal(new String("Bad String"), "My String"), false, "short annotation VS new annotation");
131
132         compare(qtest_compareInternal(false, new Boolean()), true, "short annotation VS new annotation");
133         compare(qtest_compareInternal(new Boolean(), false), true, "short annotation VS new annotation");
134         compare(qtest_compareInternal(true, new Boolean(true)), true, "short annotation VS new annotation");
135         compare(qtest_compareInternal(new Boolean(true), true), true, "short annotation VS new annotation");
136         compare(qtest_compareInternal(true, new Boolean(1)), true, "short annotation VS new annotation");
137         compare(qtest_compareInternal(false, new Boolean(false)), true, "short annotation VS new annotation");
138         compare(qtest_compareInternal(new Boolean(false), false), true, "short annotation VS new annotation");
139         compare(qtest_compareInternal(false, new Boolean(0)), true, "short annotation VS new annotation");
140         compare(qtest_compareInternal(true, new Boolean(false)), false, "short annotation VS new annotation");
141         compare(qtest_compareInternal(new Boolean(false), true), false, "short annotation VS new annotation");
142
143         compare(qtest_compareInternal(new Object(), {}), true, "short annotation VS new annotation");
144         compare(qtest_compareInternal({}, new Object()), true, "short annotation VS new annotation");
145         compare(qtest_compareInternal(new Object(), {a:1}), false, "short annotation VS new annotation");
146         compare(qtest_compareInternal({a:1}, new Object()), false, "short annotation VS new annotation");
147         compare(qtest_compareInternal({a:undefined}, new Object()), false, "short annotation VS new annotation");
148         compare(qtest_compareInternal(new Object(), {a:undefined}), false, "short annotation VS new annotation");
149     }
150
151     function test_objects_basics() {
152         compare(qtest_compareInternal({}, {}), true);
153         compare(qtest_compareInternal({}, null), false);
154         compare(qtest_compareInternal({}, undefined), false);
155         compare(qtest_compareInternal({}, 0), false);
156         compare(qtest_compareInternal({}, false), false);
157
158         // This test is a hard one, it is very important
159         // REASONS:
160         //      1) They are of the same type "object"
161         //      2) [] instanceof Object is true
162         //      3) Their properties are the same (doesn't exists)
163         compare(qtest_compareInternal({}, []), false);
164
165         compare(qtest_compareInternal({a:1}, {a:1}), true);
166         compare(qtest_compareInternal({a:1}, {a:"1"}), false);
167         compare(qtest_compareInternal({a:[]}, {a:[]}), true);
168         compare(qtest_compareInternal({a:{}}, {a:null}), false);
169         compare(qtest_compareInternal({a:1}, {}), false);
170         compare(qtest_compareInternal({}, {a:1}), false);
171
172         // Hard ones
173         compare(qtest_compareInternal({a:undefined}, {}), false);
174         compare(qtest_compareInternal({}, {a:undefined}), false);
175         compare(qtest_compareInternal(
176             {
177                 a: [{ bar: undefined }]
178             },
179             {
180                 a: [{ bat: undefined }]
181             }
182         ), false);
183     }
184
185     function test_arrays_basics() {
186         compare(qtest_compareInternal([], []), true);
187
188         // May be a hard one, can invoke a crash at execution.
189         // because their types are both "object" but null isn't
190         // like a true object, it doesn't have any property at all.
191         compare(qtest_compareInternal([], null), false);
192
193         compare(qtest_compareInternal([], undefined), false);
194         compare(qtest_compareInternal([], false), false);
195         compare(qtest_compareInternal([], 0), false);
196         compare(qtest_compareInternal([], ""), false);
197
198         // May be a hard one, but less hard
199         // than {} with [] (note the order)
200         compare(qtest_compareInternal([], {}), false);
201
202         compare(qtest_compareInternal([null],[]), false);
203         compare(qtest_compareInternal([undefined],[]), false);
204         compare(qtest_compareInternal([],[null]), false);
205         compare(qtest_compareInternal([],[undefined]), false);
206         compare(qtest_compareInternal([null],[undefined]), false);
207         compare(qtest_compareInternal([[]],[[]]), true);
208         compare(qtest_compareInternal([[],[],[]],[[],[],[]]), true);
209         compare(qtest_compareInternal(
210                                 [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
211                                 [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]),
212                                 true);
213         compare(qtest_compareInternal(
214                                 [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
215                                 [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // shorter
216                                 false);
217         compare(qtest_compareInternal(
218                                 [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
219                                 [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // deepest element not an array
220                                 false);
221
222         // same multidimensional
223         compare(qtest_compareInternal(
224                                 [1,2,3,4,5,6,7,8,9, [
225                                     1,2,3,4,5,6,7,8,9, [
226                                         1,2,3,4,5,[
227                                             [6,7,8,9, [
228                                                 [
229                                                     1,2,3,4,[
230                                                         2,3,4,[
231                                                             1,2,[
232                                                                 1,2,3,4,[
233                                                                     1,2,3,4,5,6,7,8,9,[
234                                                                         0
235                                                                     ],1,2,3,4,5,6,7,8,9
236                                                                 ],5,6,7,8,9
237                                                             ],4,5,6,7,8,9
238                                                         ],5,6,7,8,9
239                                                     ],5,6,7
240                                                 ]
241                                             ]
242                                         ]
243                                     ]
244                                 ]]],
245                                 [1,2,3,4,5,6,7,8,9, [
246                                     1,2,3,4,5,6,7,8,9, [
247                                         1,2,3,4,5,[
248                                             [6,7,8,9, [
249                                                 [
250                                                     1,2,3,4,[
251                                                         2,3,4,[
252                                                             1,2,[
253                                                                 1,2,3,4,[
254                                                                     1,2,3,4,5,6,7,8,9,[
255                                                                         0
256                                                                     ],1,2,3,4,5,6,7,8,9
257                                                                 ],5,6,7,8,9
258                                                             ],4,5,6,7,8,9
259                                                         ],5,6,7,8,9
260                                                     ],5,6,7
261                                                 ]
262                                             ]
263                                         ]
264                                     ]
265                                 ]]]),
266                                 true, "Multidimensional");
267
268         // different multidimensional
269         compare(qtest_compareInternal(
270                                 [1,2,3,4,5,6,7,8,9, [
271                                     1,2,3,4,5,6,7,8,9, [
272                                         1,2,3,4,5,[
273                                             [6,7,8,9, [
274                                                 [
275                                                     1,2,3,4,[
276                                                         2,3,4,[
277                                                             1,2,[
278                                                                 1,2,3,4,[
279                                                                     1,2,3,4,5,6,7,8,9,[
280                                                                         0
281                                                                     ],1,2,3,4,5,6,7,8,9
282                                                                 ],5,6,7,8,9
283                                                             ],4,5,6,7,8,9
284                                                         ],5,6,7,8,9
285                                                     ],5,6,7
286                                                 ]
287                                             ]
288                                         ]
289                                     ]
290                                 ]]],
291                                 [1,2,3,4,5,6,7,8,9, [
292                                     1,2,3,4,5,6,7,8,9, [
293                                         1,2,3,4,5,[
294                                             [6,7,8,9, [
295                                                 [
296                                                     1,2,3,4,[
297                                                         2,3,4,[
298                                                             1,2,[
299                                                                 '1',2,3,4,[                 // string instead of number
300                                                                     1,2,3,4,5,6,7,8,9,[
301                                                                         0
302                                                                     ],1,2,3,4,5,6,7,8,9
303                                                                 ],5,6,7,8,9
304                                                             ],4,5,6,7,8,9
305                                                         ],5,6,7,8,9
306                                                     ],5,6,7
307                                                 ]
308                                             ]
309                                         ]
310                                     ]
311                                 ]]]),
312                                 false, "Multidimensional");
313
314         // different multidimensional
315         compare(qtest_compareInternal(
316                                 [1,2,3,4,5,6,7,8,9, [
317                                     1,2,3,4,5,6,7,8,9, [
318                                         1,2,3,4,5,[
319                                             [6,7,8,9, [
320                                                 [
321                                                     1,2,3,4,[
322                                                         2,3,4,[
323                                                             1,2,[
324                                                                 1,2,3,4,[
325                                                                     1,2,3,4,5,6,7,8,9,[
326                                                                         0
327                                                                     ],1,2,3,4,5,6,7,8,9
328                                                                 ],5,6,7,8,9
329                                                             ],4,5,6,7,8,9
330                                                         ],5,6,7,8,9
331                                                     ],5,6,7
332                                                 ]
333                                             ]
334                                         ]
335                                     ]
336                                 ]]],
337                                 [1,2,3,4,5,6,7,8,9, [
338                                     1,2,3,4,5,6,7,8,9, [
339                                         1,2,3,4,5,[
340                                             [6,7,8,9, [
341                                                 [
342                                                     1,2,3,4,[
343                                                         2,3,[                   // missing an element (4)
344                                                             1,2,[
345                                                                 1,2,3,4,[
346                                                                     1,2,3,4,5,6,7,8,9,[
347                                                                         0
348                                                                     ],1,2,3,4,5,6,7,8,9
349                                                                 ],5,6,7,8,9
350                                                             ],4,5,6,7,8,9
351                                                         ],5,6,7,8,9
352                                                     ],5,6,7
353                                                 ]
354                                             ]
355                                         ]
356                                     ]
357                                 ]]]),
358                                 false, "Multidimensional");
359     }
360
361     function test_date_instances() {
362         // Date, we don't need to test Date.parse() because it returns a number.
363         // Only test the Date instances by setting them a fix date.
364         // The date use is midnight January 1, 1970
365
366         var d1 = new Date();
367         d1.setTime(0); // fix the date
368
369         var d2 = new Date();
370         d2.setTime(0); // fix the date
371
372         var d3 = new Date(); // The very now
373
374         // Anyway their types differs, just in case the code fails in the order in which it deals with date
375         compare(qtest_compareInternal(d1, 0), false); // d1.valueOf() returns 0, but d1 and 0 are different
376         // test same values date and different instances equality
377         compare(qtest_compareInternal(d1, d2), true);
378         // test different date and different instances difference
379         compare(qtest_compareInternal(d1, d3), false);
380
381         // try to fool equiv by adding a valueOf function to an object
382         // that would return the same value of a real date instance.
383         var d4 = new Date();
384         d4.setFullYear(2010);
385         d4.setMonth(1);
386         d4.setDate(1);
387         d4.setHours(1);
388         d4.setMinutes(1);
389         d4.setSeconds(1);
390         d4.setMilliseconds(1);
391         var o4 = {
392             valueOf: function () {
393                 return d4.valueOf();
394             }
395         }
396         compare(qtest_compareInternal(d4, o4), false); // o4 isn't an instance of Date
397     }
398
399
400     function test_regexp() {
401         // Must test cases that imply those traps:
402         // var a = /./;
403         // a instanceof Object;        // Oops
404         // a instanceof RegExp;        // Oops
405         // typeof a === "function";    // Oops, false in IE and Opera, true in FF and Safari ("object")
406
407         // Tests same regex with same modifiers in different order
408         var r = /foo/;
409         var r5 = /foo/gim;
410         var r6 = /foo/gmi;
411         var r7 = /foo/igm;
412         var r8 = /foo/img;
413         var r9 = /foo/mig;
414         var r10 = /foo/mgi;
415         var ri1 = /foo/i;
416         var ri2 = /foo/i;
417         var rm1 = /foo/m;
418         var rm2 = /foo/m;
419         var rg1 = /foo/g;
420         var rg2 = /foo/g;
421
422         compare(qtest_compareInternal(r5, r6), true, "Modifier order");
423         compare(qtest_compareInternal(r5, r7), true, "Modifier order");
424         compare(qtest_compareInternal(r5, r8), true, "Modifier order");
425         compare(qtest_compareInternal(r5, r9), true, "Modifier order");
426         compare(qtest_compareInternal(r5, r10), true, "Modifier order");
427         compare(qtest_compareInternal(r, r5), false, "Modifier");
428
429         compare(qtest_compareInternal(ri1, ri2), true, "Modifier");
430         compare(qtest_compareInternal(r, ri1), false, "Modifier");
431         compare(qtest_compareInternal(ri1, rm1), false, "Modifier");
432         compare(qtest_compareInternal(r, rm1), false, "Modifier");
433         compare(qtest_compareInternal(rm1, ri1), false, "Modifier");
434         compare(qtest_compareInternal(rm1, rm2), true, "Modifier");
435         compare(qtest_compareInternal(rg1, rm1), false, "Modifier");
436         compare(qtest_compareInternal(rm1, rg1), false, "Modifier");
437         compare(qtest_compareInternal(rg1, rg2), true, "Modifier");
438
439         // Different regex, same modifiers
440         var r11 = /[a-z]/gi;
441         var r13 = /[0-9]/gi; // oops! different
442         compare(qtest_compareInternal(r11, r13), false, "Regex pattern");
443
444         var r14 = /0/ig;
445         var r15 = /"0"/ig; // oops! different
446         compare(qtest_compareInternal(r14, r15), false, "Regex pattern");
447
448         var r1 = /[\n\r\u2028\u2029]/g;
449         var r2 = /[\n\r\u2028\u2029]/g;
450         var r3 = /[\n\r\u2028\u2028]/g; // differs from r1
451         var r4 = /[\n\r\u2028\u2029]/;  // differs from r1
452
453         compare(qtest_compareInternal(r1, r2), true, "Regex pattern");
454         compare(qtest_compareInternal(r1, r3), false, "Regex pattern");
455         compare(qtest_compareInternal(r1, r4), false, "Regex pattern");
456
457         // More complex regex
458         var regex1 = "^[-_.a-z0-9]+@([-_a-z0-9]+\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$";
459         var regex2 = "^[-_.a-z0-9]+@([-_a-z0-9]+\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$";
460         // regex 3 is different: '.' not escaped
461         var regex3 = "^[-_.a-z0-9]+@([-_a-z0-9]+.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$";
462
463         var r21 = new RegExp(regex1);
464         var r22 = new RegExp(regex2);
465         var r23 = new RegExp(regex3); // diff from r21, not same pattern
466         var r23a = new RegExp(regex3, "gi"); // diff from r23, not same modifier
467         var r24a = new RegExp(regex3, "ig"); // same as r23a
468
469         compare(qtest_compareInternal(r21, r22), true, "Complex Regex");
470         compare(qtest_compareInternal(r21, r23), false, "Complex Regex");
471         compare(qtest_compareInternal(r23, r23a), false, "Complex Regex");
472         compare(qtest_compareInternal(r23a, r24a), true, "Complex Regex");
473
474         // typeof r1 is "function" in some browsers and "object" in others so we must cover this test
475         var re = / /;
476         compare(qtest_compareInternal(re, function () {}), false, "Regex internal");
477         compare(qtest_compareInternal(re, {}), false, "Regex internal");
478     }
479
480
481     function test_complex_objects() {
482
483         function fn1() {
484             return "fn1";
485         }
486         function fn2() {
487             return "fn2";
488         }
489
490         // Try to invert the order of some properties to make sure it is covered.
491         // It can failed when properties are compared between unsorted arrays.
492         compare(qtest_compareInternal(
493             {
494                 a: 1,
495                 b: null,
496                 c: [{}],
497                 d: {
498                     a: 3.14159,
499                     b: false,
500                     c: {
501                         e: fn1,
502                         f: [[[]]],
503                         g: {
504                             j: {
505                                 k: {
506                                     n: {
507                                         r: "r",
508                                         s: [1,2,3],
509                                         t: undefined,
510                                         u: 0,
511                                         v: {
512                                             w: {
513                                                 x: {
514                                                     y: "Yahoo!",
515                                                     z: null
516                                                 }
517                                             }
518                                         }
519                                     },
520                                     q: [],
521                                     p: 1/0,
522                                     o: 99
523                                 },
524                                 l: undefined,
525                                 m: null
526                             }
527                         },
528                         d: 0,
529                         i: true,
530                         h: "false"
531                     }
532                 },
533                 e: undefined,
534                 g: "",
535                 h: "h",
536                 f: {},
537                 i: []
538             },
539             {
540                 a: 1,
541                 b: null,
542                 c: [{}],
543                 d: {
544                     b: false,
545                     a: 3.14159,
546                     c: {
547                         d: 0,
548                         e: fn1,
549                         f: [[[]]],
550                         g: {
551                             j: {
552                                 k: {
553                                     n: {
554                                         r: "r",
555                                         t: undefined,
556                                         u: 0,
557                                         s: [1,2,3],
558                                         v: {
559                                             w: {
560                                                 x: {
561                                                     z: null,
562                                                     y: "Yahoo!"
563                                                 }
564                                             }
565                                         }
566                                     },
567                                     o: 99,
568                                     p: 1/0,
569                                     q: []
570                                 },
571                                 l: undefined,
572                                 m: null
573                             }
574                         },
575                         i: true,
576                         h: "false"
577                     }
578                 },
579                 e: undefined,
580                 g: "",
581                 f: {},
582                 h: "h",
583                 i: []
584             }
585         ), true);
586
587         compare(qtest_compareInternal(
588             {
589                 a: 1,
590                 b: null,
591                 c: [{}],
592                 d: {
593                     a: 3.14159,
594                     b: false,
595                     c: {
596                         d: 0,
597                         e: fn1,
598                         f: [[[]]],
599                         g: {
600                             j: {
601                                 k: {
602                                     n: {
603                                         //r: "r",   // different: missing a property
604                                         s: [1,2,3],
605                                         t: undefined,
606                                         u: 0,
607                                         v: {
608                                             w: {
609                                                 x: {
610                                                     y: "Yahoo!",
611                                                     z: null
612                                                 }
613                                             }
614                                         }
615                                     },
616                                     o: 99,
617                                     p: 1/0,
618                                     q: []
619                                 },
620                                 l: undefined,
621                                 m: null
622                             }
623                         },
624                         h: "false",
625                         i: true
626                     }
627                 },
628                 e: undefined,
629                 f: {},
630                 g: "",
631                 h: "h",
632                 i: []
633             },
634             {
635                 a: 1,
636                 b: null,
637                 c: [{}],
638                 d: {
639                     a: 3.14159,
640                     b: false,
641                     c: {
642                         d: 0,
643                         e: fn1,
644                         f: [[[]]],
645                         g: {
646                             j: {
647                                 k: {
648                                     n: {
649                                         r: "r",
650                                         s: [1,2,3],
651                                         t: undefined,
652                                         u: 0,
653                                         v: {
654                                             w: {
655                                                 x: {
656                                                     y: "Yahoo!",
657                                                     z: null
658                                                 }
659                                             }
660                                         }
661                                     },
662                                     o: 99,
663                                     p: 1/0,
664                                     q: []
665                                 },
666                                 l: undefined,
667                                 m: null
668                             }
669                         },
670                         h: "false",
671                         i: true
672                     }
673                 },
674                 e: undefined,
675                 f: {},
676                 g: "",
677                 h: "h",
678                 i: []
679             }
680         ), false);
681
682         compare(qtest_compareInternal(
683             {
684                 a: 1,
685                 b: null,
686                 c: [{}],
687                 d: {
688                     a: 3.14159,
689                     b: false,
690                     c: {
691                         d: 0,
692                         e: fn1,
693                         f: [[[]]],
694                         g: {
695                             j: {
696                                 k: {
697                                     n: {
698                                         r: "r",
699                                         s: [1,2,3],
700                                         t: undefined,
701                                         u: 0,
702                                         v: {
703                                             w: {
704                                                 x: {
705                                                     y: "Yahoo!",
706                                                     z: null
707                                                 }
708                                             }
709                                         }
710                                     },
711                                     o: 99,
712                                     p: 1/0,
713                                     q: []
714                                 },
715                                 l: undefined,
716                                 m: null
717                             }
718                         },
719                         h: "false",
720                         i: true
721                     }
722                 },
723                 e: undefined,
724                 f: {},
725                 g: "",
726                 h: "h",
727                 i: []
728             },
729             {
730                 a: 1,
731                 b: null,
732                 c: [{}],
733                 d: {
734                     a: 3.14159,
735                     b: false,
736                     c: {
737                         d: 0,
738                         e: fn1,
739                         f: [[[]]],
740                         g: {
741                             j: {
742                                 k: {
743                                     n: {
744                                         r: "r",
745                                         s: [1,2,3],
746                                         //t: undefined,                 // different: missing a property with an undefined value
747                                         u: 0,
748                                         v: {
749                                             w: {
750                                                 x: {
751                                                     y: "Yahoo!",
752                                                     z: null
753                                                 }
754                                             }
755                                         }
756                                     },
757                                     o: 99,
758                                     p: 1/0,
759                                     q: []
760                                 },
761                                 l: undefined,
762                                 m: null
763                             }
764                         },
765                         h: "false",
766                         i: true
767                     }
768                 },
769                 e: undefined,
770                 f: {},
771                 g: "",
772                 h: "h",
773                 i: []
774             }
775         ), false);
776
777         compare(qtest_compareInternal(
778             {
779                 a: 1,
780                 b: null,
781                 c: [{}],
782                 d: {
783                     a: 3.14159,
784                     b: false,
785                     c: {
786                         d: 0,
787                         e: fn1,
788                         f: [[[]]],
789                         g: {
790                             j: {
791                                 k: {
792                                     n: {
793                                         r: "r",
794                                         s: [1,2,3],
795                                         t: undefined,
796                                         u: 0,
797                                         v: {
798                                             w: {
799                                                 x: {
800                                                     y: "Yahoo!",
801                                                     z: null
802                                                 }
803                                             }
804                                         }
805                                     },
806                                     o: 99,
807                                     p: 1/0,
808                                     q: []
809                                 },
810                                 l: undefined,
811                                 m: null
812                             }
813                         },
814                         h: "false",
815                         i: true
816                     }
817                 },
818                 e: undefined,
819                 f: {},
820                 g: "",
821                 h: "h",
822                 i: []
823             },
824             {
825                 a: 1,
826                 b: null,
827                 c: [{}],
828                 d: {
829                     a: 3.14159,
830                     b: false,
831                     c: {
832                         d: 0,
833                         e: fn1,
834                         f: [[[]]],
835                         g: {
836                             j: {
837                                 k: {
838                                     n: {
839                                         r: "r",
840                                         s: [1,2,3],
841                                         t: undefined,
842                                         u: 0,
843                                         v: {
844                                             w: {
845                                                 x: {
846                                                     y: "Yahoo!",
847                                                     z: null
848                                                 }
849                                             }
850                                         }
851                                     },
852                                     o: 99,
853                                     p: 1/0,
854                                     q: {}           // different was []
855                                 },
856                                 l: undefined,
857                                 m: null
858                             }
859                         },
860                         h: "false",
861                         i: true
862                     }
863                 },
864                 e: undefined,
865                 f: {},
866                 g: "",
867                 h: "h",
868                 i: []
869             }
870         ), false);
871
872         var same1 = {
873             a: [
874                 "string", null, 0, "1", 1, {
875                     prop: null,
876                     foo: [1,2,null,{}, [], [1,2,3]],
877                     bar: undefined
878                 }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
879             ],
880             unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
881             b: "b",
882             c: fn1
883         };
884
885         var same2 = {
886             a: [
887                 "string", null, 0, "1", 1, {
888                     prop: null,
889                     foo: [1,2,null,{}, [], [1,2,3]],
890                     bar: undefined
891                 }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
892             ],
893             unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
894             b: "b",
895             c: fn1
896         };
897
898         var diff1 = {
899             a: [
900                 "string", null, 0, "1", 1, {
901                     prop: null,
902                     foo: [1,2,null,{}, [], [1,2,3,4]], // different: 4 was add to the array
903                     bar: undefined
904                 }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
905             ],
906             unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
907             b: "b",
908             c: fn1
909         };
910
911         var diff2 = {
912             a: [
913                 "string", null, 0, "1", 1, {
914                     prop: null,
915                     foo: [1,2,null,{}, [], [1,2,3]],
916                     newprop: undefined, // different: newprop was added
917                     bar: undefined
918                 }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
919             ],
920             unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
921             b: "b",
922             c: fn1
923         };
924
925         var diff3 = {
926             a: [
927                 "string", null, 0, "1", 1, {
928                     prop: null,
929                     foo: [1,2,null,{}, [], [1,2,3]],
930                     bar: undefined
931                 }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ α" // different: missing last char
932             ],
933             unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
934             b: "b",
935             c: fn1
936         };
937
938         var diff4 = {
939             a: [
940                 "string", null, 0, "1", 1, {
941                     prop: null,
942                     foo: [1,2,undefined,{}, [], [1,2,3]], // different: undefined instead of null
943                     bar: undefined
944                 }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
945             ],
946             unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
947             b: "b",
948             c: fn1
949         };
950
951         var diff5 = {
952             a: [
953                 "string", null, 0, "1", 1, {
954                     prop: null,
955                     foo: [1,2,null,{}, [], [1,2,3]],
956                     bat: undefined // different: property name not "bar"
957                 }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
958             ],
959             unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
960             b: "b",
961             c: fn1
962         };
963
964         compare(qtest_compareInternal(same1, same2), true);
965         compare(qtest_compareInternal(same2, same1), true);
966         compare(qtest_compareInternal(same2, diff1), false);
967         compare(qtest_compareInternal(diff1, same2), false);
968
969         compare(qtest_compareInternal(same1, diff1), false);
970         compare(qtest_compareInternal(same1, diff2), false);
971         compare(qtest_compareInternal(same1, diff3), false);
972         compare(qtest_compareInternal(same1, diff3), false);
973         compare(qtest_compareInternal(same1, diff4), false);
974         compare(qtest_compareInternal(same1, diff5), false);
975         compare(qtest_compareInternal(diff5, diff1), false);
976     }
977
978
979     function test_complex_arrays() {
980
981         function fn() {
982         }
983
984         compare(qtest_compareInternal(
985                     [1, 2, 3, true, {}, null, [
986                         {
987                             a: ["", '1', 0]
988                         },
989                         5, 6, 7
990                     ], "foo"],
991                     [1, 2, 3, true, {}, null, [
992                         {
993                             a: ["", '1', 0]
994                         },
995                         5, 6, 7
996                     ], "foo"]),
997                 true);
998
999         compare(qtest_compareInternal(
1000                     [1, 2, 3, true, {}, null, [
1001                         {
1002                             a: ["", '1', 0]
1003                         },
1004                         5, 6, 7
1005                     ], "foo"],
1006                     [1, 2, 3, true, {}, null, [
1007                         {
1008                             b: ["", '1', 0]         // not same property name
1009                         },
1010                         5, 6, 7
1011                     ], "foo"]),
1012                 false);
1013
1014         var a = [{
1015             b: fn,
1016             c: false,
1017             "do": "reserved word",
1018             "for": {
1019                 ar: [3,5,9,"hey!", [], {
1020                     ar: [1,[
1021                         3,4,6,9, null, [], []
1022                     ]],
1023                     e: fn,
1024                     f: undefined
1025                 }]
1026             },
1027             e: 0.43445
1028         }, 5, "string", 0, fn, false, null, undefined, 0, [
1029             4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
1030         ], [], [[[], "foo", null, {
1031             n: 1/0,
1032             z: {
1033                 a: [3,4,5,6,"yep!", undefined, undefined],
1034                 b: {}
1035             }
1036         }, {}]]];
1037
1038         compare(qtest_compareInternal(a,
1039                 [{
1040                     b: fn,
1041                     c: false,
1042                     "do": "reserved word",
1043                     "for": {
1044                         ar: [3,5,9,"hey!", [], {
1045                             ar: [1,[
1046                                 3,4,6,9, null, [], []
1047                             ]],
1048                             e: fn,
1049                             f: undefined
1050                         }]
1051                     },
1052                     e: 0.43445
1053                 }, 5, "string", 0, fn, false, null, undefined, 0, [
1054                     4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
1055                 ], [], [[[], "foo", null, {
1056                     n: 1/0,
1057                     z: {
1058                         a: [3,4,5,6,"yep!", undefined, undefined],
1059                         b: {}
1060                     }
1061                 }, {}]]]), true);
1062
1063         compare(qtest_compareInternal(a,
1064                 [{
1065                     b: fn,
1066                     c: false,
1067                     "do": "reserved word",
1068                     "for": {
1069                         ar: [3,5,9,"hey!", [], {
1070                             ar: [1,[
1071                                 3,4,6,9, null, [], []
1072                             ]],
1073                             e: fn,
1074                             f: undefined
1075                         }]
1076                     },
1077                     e: 0.43445
1078                 }, 5, "string", 0, fn, false, null, undefined, 0, [
1079                     4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[2]]]], "3"], {}, 1/0    // different: [[[[[2]]]]] instead of [[[[[3]]]]]
1080                 ], [], [[[], "foo", null, {
1081                     n: 1/0,
1082                     z: {
1083                         a: [3,4,5,6,"yep!", undefined, undefined],
1084                         b: {}
1085                     }
1086                 }, {}]]]), false);
1087
1088         compare(qtest_compareInternal(a,
1089                 [{
1090                     b: fn,
1091                     c: false,
1092                     "do": "reserved word",
1093                     "for": {
1094                         ar: [3,5,9,"hey!", [], {
1095                             ar: [1,[
1096                                 3,4,6,9, null, [], []
1097                             ]],
1098                             e: fn,
1099                             f: undefined
1100                         }]
1101                     },
1102                     e: 0.43445
1103                 }, 5, "string", 0, fn, false, null, undefined, 0, [
1104                     4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
1105                 ], [], [[[], "foo", null, {
1106                     n: -1/0,                                                                // different, -Infinity instead of Infinity
1107                     z: {
1108                         a: [3,4,5,6,"yep!", undefined, undefined],
1109                         b: {}
1110                     }
1111                 }, {}]]]), false);
1112
1113         compare(qtest_compareInternal(a,
1114                 [{
1115                     b: fn,
1116                     c: false,
1117                     "do": "reserved word",
1118                     "for": {
1119                         ar: [3,5,9,"hey!", [], {
1120                             ar: [1,[
1121                                 3,4,6,9, null, [], []
1122                             ]],
1123                             e: fn,
1124                             f: undefined
1125                         }]
1126                     },
1127                     e: 0.43445
1128                 }, 5, "string", 0, fn, false, null, undefined, 0, [
1129                     4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
1130                 ], [], [[[], "foo", {                                                       // different: null is missing
1131                     n: 1/0,
1132                     z: {
1133                         a: [3,4,5,6,"yep!", undefined, undefined],
1134                         b: {}
1135                     }
1136                 }, {}]]]), false);
1137
1138         compare(qtest_compareInternal(a,
1139                 [{
1140                     b: fn,
1141                     c: false,
1142                     "do": "reserved word",
1143                     "for": {
1144                         ar: [3,5,9,"hey!", [], {
1145                             ar: [1,[
1146                                 3,4,6,9, null, [], []
1147                             ]],
1148                             e: fn
1149                                                                                     // different: missing property f: undefined
1150                         }]
1151                     },
1152                     e: 0.43445
1153                 }, 5, "string", 0, fn, false, null, undefined, 0, [
1154                     4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
1155                 ], [], [[[], "foo", null, {
1156                     n: 1/0,
1157                     z: {
1158                         a: [3,4,5,6,"yep!", undefined, undefined],
1159                         b: {}
1160                     }
1161                 }, {}]]]), false);
1162     }
1163
1164
1165     function test_prototypal_inheritance() {
1166         function Gizmo(id) {
1167             this.id = id;
1168         }
1169
1170         function Hoozit(id) {
1171             this.id = id;
1172         }
1173         Hoozit.prototype = new Gizmo();
1174
1175         var gizmo = new Gizmo("ok");
1176         var hoozit = new Hoozit("ok");
1177
1178         // Try this test many times after test on instances that hold function
1179         // to make sure that our code does not mess with last object constructor memoization.
1180         compare(qtest_compareInternal(function () {}, function () {}), false);
1181
1182         // Hoozit inherit from Gizmo
1183         // hoozit instanceof Hoozit; // true
1184         // hoozit instanceof Gizmo; // true
1185         compare(qtest_compareInternal(hoozit, gizmo), true);
1186
1187         Gizmo.prototype.bar = true; // not a function just in case we skip them
1188
1189         // Hoozit inherit from Gizmo
1190         // They are equivalent
1191         compare(qtest_compareInternal(hoozit, gizmo), true);
1192
1193         // Make sure this is still true !important
1194         // The reason for this is that I forgot to reset the last
1195         // caller to where it were called from.
1196         compare(qtest_compareInternal(function () {}, function () {}), false);
1197
1198         // Make sure this is still true !important
1199         compare(qtest_compareInternal(hoozit, gizmo), true);
1200
1201         Hoozit.prototype.foo = true; // not a function just in case we skip them
1202
1203         // Gizmo does not inherit from Hoozit
1204         // gizmo instanceof Gizmo; // true
1205         // gizmo instanceof Hoozit; // false
1206         // They are not equivalent
1207         compare(qtest_compareInternal(hoozit, gizmo), false);
1208
1209         // Make sure this is still true !important
1210         compare(qtest_compareInternal(function () {}, function () {}), false);
1211     }
1212
1213
1214     function test_instances() {
1215         function A() {}
1216         var a1 = new A();
1217         var a2 = new A();
1218
1219         function B() {
1220             this.fn = function () {};
1221         }
1222         var b1 = new B();
1223         var b2 = new B();
1224
1225         compare(qtest_compareInternal(a1, a2), true, "Same property, same constructor");
1226
1227         // b1.fn and b2.fn are functions but they are different references
1228         // But we decided to skip function for instances.
1229         expectFail("", "Don't know if we want to take over function checking like in QUnit")
1230         compare(qtest_compareInternal(b1, b2), true, "Same property, same constructor");
1231         compare(qtest_compareInternal(a1, b1), false, "Same properties but different constructor"); // failed
1232
1233         function Car(year) {
1234             var privateVar = 0;
1235             this.year = year;
1236             this.isOld = function() {
1237                 return year > 10;
1238             };
1239         }
1240
1241         function Human(year) {
1242             var privateVar = 1;
1243             this.year = year;
1244             this.isOld = function() {
1245                 return year > 80;
1246             };
1247         }
1248
1249         var car = new Car(30);
1250         var carSame = new Car(30);
1251         var carDiff = new Car(10);
1252         var human = new Human(30);
1253
1254         var diff = {
1255             year: 30
1256         };
1257
1258         var same = {
1259             year: 30,
1260             isOld: function () {}
1261         };
1262
1263         compare(qtest_compareInternal(car, car), true);
1264         compare(qtest_compareInternal(car, carDiff), false);
1265         compare(qtest_compareInternal(car, carSame), true);
1266         compare(qtest_compareInternal(car, human), false);
1267     }
1268
1269
1270     function test_complex_instances_nesting() {
1271     //"Complex Instances Nesting (with function value in literals and/or in nested instances)"
1272         function A(fn) {
1273             this.a = {};
1274             this.fn = fn;
1275             this.b = {a: []};
1276             this.o = {};
1277             this.fn1 = fn;
1278         }
1279         function B(fn) {
1280             this.fn = fn;
1281             this.fn1 = function () {};
1282             this.a = new A(function () {});
1283         }
1284
1285         function fnOutside() {
1286         }
1287
1288         function C(fn) {
1289             function fnInside() {
1290             }
1291             this.x = 10;
1292             this.fn = fn;
1293             this.fn1 = function () {};
1294             this.fn2 = fnInside;
1295             this.fn3 = {
1296                 a: true,
1297                 b: fnOutside // ok make reference to a function in all instances scope
1298             };
1299             this.o1 = {};
1300
1301             // This function will be ignored.
1302             // Even if it is not visible for all instances (e.g. locked in a closures),
1303             // it is from a  property that makes part of an instance (e.g. from the C constructor)
1304             this.b1 = new B(function () {});
1305             this.b2 = new B({
1306                 x: {
1307                     b2: new B(function() {})
1308                 }
1309             });
1310         }
1311
1312         function D(fn) {
1313             function fnInside() {
1314             }
1315             this.x = 10;
1316             this.fn = fn;
1317             this.fn1 = function () {};
1318             this.fn2 = fnInside;
1319             this.fn3 = {
1320                 a: true,
1321                 b: fnOutside, // ok make reference to a function in all instances scope
1322
1323                 // This function won't be ingored.
1324                 // It isn't visible for all C insances
1325                 // and it is not in a property of an instance. (in an Object instances e.g. the object literal)
1326                 c: fnInside
1327             };
1328             this.o1 = {};
1329
1330             // This function will be ignored.
1331             // Even if it is not visible for all instances (e.g. locked in a closures),
1332             // it is from a  property that makes part of an instance (e.g. from the C constructor)
1333             this.b1 = new B(function () {});
1334             this.b2 = new B({
1335                 x: {
1336                     b2: new B(function() {})
1337                 }
1338             });
1339         }
1340
1341         function E(fn) {
1342             function fnInside() {
1343             }
1344             this.x = 10;
1345             this.fn = fn;
1346             this.fn1 = function () {};
1347             this.fn2 = fnInside;
1348             this.fn3 = {
1349                 a: true,
1350                 b: fnOutside // ok make reference to a function in all instances scope
1351             };
1352             this.o1 = {};
1353
1354             // This function will be ignored.
1355             // Even if it is not visible for all instances (e.g. locked in a closures),
1356             // it is from a  property that makes part of an instance (e.g. from the C constructor)
1357             this.b1 = new B(function () {});
1358             this.b2 = new B({
1359                 x: {
1360                     b1: new B({a: function() {}}),
1361                     b2: new B(function() {})
1362                 }
1363             });
1364         }
1365
1366
1367         var a1 = new A(function () {});
1368         var a2 = new A(function () {});
1369         expectFail("", "Don't know if we want to take over function checking like in QUnit")
1370         compare(qtest_compareInternal(a1, a2), true);
1371
1372         compare(qtest_compareInternal(a1, a2), true); // different instances
1373
1374         var b1 = new B(function () {});
1375         var b2 = new B(function () {});
1376         compare(qtest_compareInternal(a1, a2), true);
1377
1378         var c1 = new C(function () {});
1379         var c2 = new C(function () {});
1380         compare(qtest_compareInternal(c1, c2), true);
1381
1382         var d1 = new D(function () {});
1383         var d2 = new D(function () {});
1384         compare(qtest_compareInternal(d1, d2), false);
1385
1386         var e1 = new E(function () {});
1387         var e2 = new E(function () {});
1388         compare(qtest_compareInternal(e1, e2), false);
1389
1390     }
1391 }