2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an
8 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed
9 * or implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
19 * Contributor(s): coliver@mminternet.com, pschwartau@netscape.com
22 * SUMMARY: Testing scope with nested functions
24 * From correspondence with Christopher Oliver <coliver@mminternet.com>:
26 * > Running this test with Rhino produces the following exception:
28 * > uncaught JavaScript exception: undefined: Cannot find default value for
31 * > This is due to a bug in org.mozilla.javascript.NativeCall which doesn't
32 * > implement toString or valueOf or override getDefaultValue.
33 * > However, even after I hacked in an implementation of getDefaultValue in
34 * > NativeCall, Rhino still produces a different result then SpiderMonkey:
40 * Note the results should be:
46 * This is what we are checking for in this testcase -
48 //-----------------------------------------------------------------------------
51 var summary = 'Testing scope with nested functions';
52 var statprefix = 'Section ';
53 var statsuffix = ' of test -';
54 var self = this; // capture a reference to the global object;
55 var cnGlobal = self.toString();
56 var cnObject = (new Object).toString();
58 var actualvalues = [];
59 var expectedvalues = [];
66 capture(this.toString());
71 capture(this.toString());
79 var obj = new a(); // captures actualvalues[0]
80 obj.c(); // captures actualvalues[1], actualvalues[2]
83 // The values we expect - see introduction above -
84 expectedvalues[0] = cnGlobal;
85 expectedvalues[1] = cnObject;
86 expectedvalues[2] = cnGlobal;
90 //-----------------------------------------------------------------------------
92 //-----------------------------------------------------------------------------
98 actualvalues[UBound] = val;
99 statusitems[UBound] = getStatus(UBound);
107 printBugNumber (bug);
108 printStatus (summary);
110 for (var i=0; i<UBound; i++)
112 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
119 function getStatus(i)
121 return statprefix + i + statsuffix;