js/src/tests/ecma_3/Function/regress-193555.js

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

mercurial