Debian Codegraph @

rhino/testsrc/tests/ecma_3/Function/regress-193555.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 /*
7 *
8 * Date: 17 February 2003
9 * SUMMARY: Testing access to function name from inside function
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=193555
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-193555.js';
16 var UBound = 0;
17 var BUGNUMBER = 193555;
18 var summary = 'Testing access to function name from inside function';
19 var status = '';
20 var statusitems = [];
21 var actual = '';
22 var actualvalues = [];
23 var expect= '';
24 var expectedvalues = [];
25
26
27 // test via function statement
28 status = inSection(1);
29 function f() {return f.toString();};
30 actual = f();
31 expect = f.toString();
32 addThis();
33
34 // test via function expression
35 status = inSection(2);
36 var x = function g() {return g.toString();};
37 actual = x();
38 expect = x.toString();
39 addThis();
40
41 // test via eval() outside function
42 status = inSection(3);
43 eval ('function a() {return a.toString();}');
44 actual = a();
45 expect = a.toString();
46 addThis();
47
48 status = inSection(4);
49 eval ('var y = function b() {return b.toString();}');
50 actual = y();
51 expect = y.toString();
52 addThis();
53
54 // test via eval() inside function
55 status = inSection(5);
56 function c() {return eval('c').toString();};
57 actual = c();
58 expect = c.toString();
59 addThis();
60
61 status = inSection(6);
62 var z = function d() {return eval('d').toString();};
63 actual = z();
64 expect = z.toString();
65 addThis();
66
67 // test via two evals!
68 status = inSection(7);
69 eval('var w = function e() {return eval("e").toString();}');
70 actual = w();
71 expect = w.toString();
72 addThis();
73
74
75
76 //-----------------------------------------------------------------------------
77 test();
78 //-----------------------------------------------------------------------------
79
80
81
82 function addThis()
83 {
84 statusitems[UBound] = status;
85 actualvalues[UBound] = actual;
86 expectedvalues[UBound] = expect;
87 UBound++;
88 }
89
90
91 function test()
92 {
93 enterFunc('test');
94 printBugNumber(BUGNUMBER);
95 printStatus(summary);
96
97 for (var i=0; i<UBound; i++)
98 {
99 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
100 }
101
102 exitFunc ('test');
103 }