Home | History | Annotate | Download | only in Regress
      1 /*
      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/
      6 *
      7 * Software distributed under the License is distributed on an "AS
      8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
      9 * implied. See the License for the specific language governing
     10 * rights and limitations under the License.
     11 *
     12 * The Original Code is mozilla.org code.
     13 *
     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. All
     17 * Rights Reserved.
     18 *
     19 * Contributor(s): brendan (at) mozilla.org, pschwartau (at) netscape.com
     20 * Date: 15 Feb 2001
     21 *
     22 * SUMMARY: calling obj.eval(str)
     23 *
     24 * See http://bugzilla.mozilla.org/show_bug.cgi?id=68498
     25 * See http://bugzilla.mozilla.org/showattachment.cgi?attach_id=25251
     26 *
     27 * Brendan:
     28 *
     29 * "Backward compatibility: support calling obj.eval(str), which evaluates
     30 *   str using obj as the scope chain and variable object."
     31 */
     32 //-------------------------------------------------------------------------------------------------
     33 var bug = 68498;
     34 var summary = 'Testing calling obj.eval(str)';
     35 var statprefix = '; currently at expect[';
     36 var statsuffix = '] within test -';
     37 var actual = [ ];
     38 var expect = [ ];
     39 
     40 
     41 // Capture a reference to the global object -
     42 var self = this;
     43 
     44 // This function is the heart of the test -
     45 function f(s) {self.eval(s); return y;}
     46 
     47 
     48 // Set the actual-results array -
     49 actual[0] = f('var y = 43');
     50 actual[1] = 'y' in self && y;
     51 actual[2] = delete y;
     52 actual[3] = 'y' in self;
     53 
     54 // Set the expected-results array -
     55 expect[0] = 43;
     56 expect[1] = 43;
     57 expect[2] = true;
     58 expect[3] = false;
     59 
     60 
     61 //-------------------------------------------------------------------------------------------------
     62 test();
     63 //-------------------------------------------------------------------------------------------------
     64 
     65 
     66 function test()
     67 {
     68   enterFunc ('test');
     69   printBugNumber (bug);
     70   printStatus (summary);
     71 
     72   for (var i in expect)
     73   {
     74     reportCompare(expect[i], actual[i], getStatus(i));
     75   }
     76 
     77   exitFunc ('test');
     78 }
     79 
     80 
     81 function getStatus(i)
     82 {
     83   return (summary  +  statprefix  +  i  +  statsuffix);
     84 }
     85