Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/regress-164697.js

raw symbols SCIP
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 var gTestfile = 'regress-164697.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 164697;
9 var summary = '(instance.__parent__ == constructor.__parent__)';
10 var actual = '';
11 var expect = '';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 expect = 'true';
17
18 runtest('{}', 'Object');
19 runtest('new Object()', 'Object');
20
21 // see https://bugzilla.mozilla.org/show_bug.cgi?id=321669
22 // for why this test is not contained in a function.
23 actual = (function (){}).__proto__ == Function.prototype;
24 reportCompare('true', actual+'',
25 '(function (){}).__proto__ == Function.prototype');
26
27 runtest('new Function(";")', 'Function');
28
29 runtest('[]', 'Array');
30 runtest('new Array()', 'Array');
31
32 runtest('""', 'String');
33 runtest('new String()', 'String');
34
35 runtest('true', 'Boolean');
36 runtest('new Boolean()', 'Boolean');
37
38 runtest('1', 'Number');
39 runtest('new Number("1")', 'Number');
40
41 runtest('new Date()', 'Date');
42
43 runtest('/x/', 'RegExp');
44 runtest('new RegExp("x")', 'RegExp');
45
46 runtest('new Error()', 'Error');
47
48 function runtest(myinstance, myconstructor)
49 {
50 var expr;
51 var actual;
52
53 try
54 {
55 expr = '(' + myinstance + ').__parent__ == ' +
56 myconstructor + '.__parent__';
57 printStatus(expr);
58 actual = eval(expr).toString();
59 }
60 catch(ex)
61 {
62 actual = ex + '';
63 }
64
65 reportCompare(expect, actual, expr);
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 }