|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 //----------------------------------------------------------------------------- |
|
7 var BUGNUMBER = 164697; |
|
8 var summary = '(parent(instance) == parent(constructor))'; |
|
9 var actual = ''; |
|
10 var expect = ''; |
|
11 |
|
12 printBugNumber(BUGNUMBER); |
|
13 printStatus (summary); |
|
14 |
|
15 expect = 'true'; |
|
16 |
|
17 runtest('{}', 'Object'); |
|
18 runtest('new Object()', 'Object'); |
|
19 |
|
20 // see https://bugzilla.mozilla.org/show_bug.cgi?id=321669 |
|
21 // for why this test is not contained in a function. |
|
22 actual = (function (){}).__proto__ == Function.prototype; |
|
23 reportCompare('true', actual+'', |
|
24 '(function (){}).__proto__ == Function.prototype'); |
|
25 |
|
26 runtest('new Function(";")', 'Function'); |
|
27 |
|
28 runtest('[]', 'Array'); |
|
29 runtest('new Array()', 'Array'); |
|
30 |
|
31 runtest('new String()', 'String'); |
|
32 |
|
33 runtest('new Boolean()', 'Boolean'); |
|
34 |
|
35 runtest('new Number("1")', 'Number'); |
|
36 |
|
37 runtest('new Date()', 'Date'); |
|
38 |
|
39 runtest('/x/', 'RegExp'); |
|
40 runtest('new RegExp("x")', 'RegExp'); |
|
41 |
|
42 runtest('new Error()', 'Error'); |
|
43 |
|
44 function runtest(myinstance, myconstructor) |
|
45 { |
|
46 var expr; |
|
47 var actual; |
|
48 |
|
49 if (typeof parent === "function") |
|
50 { |
|
51 try |
|
52 { |
|
53 expr = |
|
54 'parent(' + myinstance + ') == ' + |
|
55 'parent(' + myconstructor + ')'; |
|
56 printStatus(expr); |
|
57 actual = eval(expr).toString(); |
|
58 } |
|
59 catch(ex) |
|
60 { |
|
61 actual = ex + ''; |
|
62 } |
|
63 |
|
64 reportCompare(expect, actual, expr); |
|
65 } |
|
66 |
|
67 try |
|
68 { |
|
69 expr = '(' + myinstance + ').__proto__ == ' + |
|
70 myconstructor + '.prototype'; |
|
71 printStatus(expr); |
|
72 actual = eval(expr).toString(); |
|
73 } |
|
74 catch(ex) |
|
75 { |
|
76 actual = ex + ''; |
|
77 } |
|
78 |
|
79 reportCompare(expect, actual, expr); |
|
80 } |