Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-127557.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: 06 Mar 2002
9 * SUMMARY: Testing cloned function objects
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=127557
11 *
12 * Before this bug was fixed, this testcase would error when run:
13 *
14 * ReferenceError: h_peer is not defined
15 *
16 * The line |g.prototype = new Object| below is essential: this is
17 * what was confusing the engine in its attempt to look up h_peer
18 */
19 //-----------------------------------------------------------------------------
20 var gTestfile = 'regress-127557.js';
21 var UBound = 0;
22 var BUGNUMBER = 127557;
23 var summary = 'Testing cloned function objects';
24 var cnCOMMA = ',';
25 var status = '';
26 var statusitems = [];
27 var actual = '';
28 var actualvalues = [];
29 var expect= '';
30 var expectedvalues = [];
31
32
33 function f(x,y)
34 {
35 function h()
36 {
37 return h_peer();
38 }
39 function h_peer()
40 {
41 return (x + cnCOMMA + y);
42 }
43 return h;
44 }
45
46 if (typeof clone == 'function')
47 {
48 status = inSection(1);
49 var g = clone(f);
50 g.prototype = new Object;
51 var h = g(5,6);
52 actual = h();
53 expect = '5,6';
54 addThis();
55 }
56 else
57 {
58 reportCompare('Test not run', 'Test not run', 'shell only test requires clone()');
59 }
60
61
62
63 //-----------------------------------------------------------------------------
64 test();
65 //-----------------------------------------------------------------------------
66
67
68
69 function addThis()
70 {
71 statusitems[UBound] = status;
72 actualvalues[UBound] = actual;
73 expectedvalues[UBound] = expect;
74 UBound++;
75 }
76
77
78 function test()
79 {
80 enterFunc('test');
81 printBugNumber(BUGNUMBER);
82 printStatus(summary);
83
84 for (var i=0; i<UBound; i++)
85 {
86 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
87 }
88
89 exitFunc ('test');
90 }
91