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: create a Deletable local variable using eval
     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 * "Demonstrate the creation of a Deletable local variable using eval"
     30 */
     31 //-------------------------------------------------------------------------------------------------
     32 var bug = 68498;
     33 var summary = 'Creating a Deletable local variable using eval';
     34 var statprefix = '; currently at expect[';
     35 var statsuffix = '] within test -';
     36 var actual = [ ];
     37 var expect = [ ];
     38 
     39 
     40 // Capture a reference to the global object -
     41 var self = this;
     42 
     43 // This function is the heart of the test -
     44 function f(s) {eval(s); actual[0]=y; return delete y;}
     45 
     46 
     47 // Set the actual-results array. The next line will set actual[0] and actual[1] in one shot
     48 actual[1] = f('var y = 42');
     49 actual[2] = 'y' in self && y;
     50 
     51 // Set the expected-results array -
     52 expect[0] = 42;
     53 expect[1] = true;
     54 expect[2] = false;
     55 
     56 
     57 //-------------------------------------------------------------------------------------------------
     58 test();
     59 //-------------------------------------------------------------------------------------------------
     60 
     61 
     62 function test()
     63 {
     64   enterFunc ('test');
     65   printBugNumber (bug);
     66   printStatus (summary);
     67 
     68   for (var i in expect)
     69   {
     70     reportCompare(expect[i], actual[i], getStatus(i));
     71   }
     72 
     73   exitFunc ('test');
     74 }
     75 
     76 
     77 function getStatus(i)
     78 {
     79   return (summary  +  statprefix  +  i  +  statsuffix);
     80 }
     81