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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     6 /*
     7  * Date: 2001-06-14
     8  *
     9  * SUMMARY: Regression test for Bugzilla bug 85880
    10  *
    11  * Rhino interpreted mode was nulling out the arguments object of a
    12  * function if it happened to call another function inside its body.
    13  *
    14  * See http://bugzilla.mozilla.org/show_bug.cgi?id=85880
    15  *
    16  */
    17 //-----------------------------------------------------------------------------
    18 var UBound = 0;
    19 var BUGNUMBER = 85880;
    20 var summary = 'Arguments object of g(){f()} should not be null';
    21 var cnNonNull = 'Arguments != null';
    22 var cnNull = 'Arguments == null';
    23 var cnRecurse = true;
    24 var status = '';
    25 var statusitems = [];
    26 var actual = '';
    27 var actualvalues = [];
    28 var expect= '';
    29 var expectedvalues = [];
    32 function f1(x)
    33 {
    34 }
    37 function f2()
    38 {
    39   return f2.arguments;
    40 }
    41 status = 'Section A of test';
    42 actual = (f2() == null);
    43 expect = false;
    44 addThis();
    46 status = 'Section B of test';
    47 actual = (f2(0) == null);
    48 expect = false;
    49 addThis();
    52 function f3()
    53 {
    54   f1();
    55   return f3.arguments;
    56 }
    57 status = 'Section C of test';
    58 actual = (f3() == null);
    59 expect = false;
    60 addThis();
    62 status = 'Section D of test';
    63 actual = (f3(0) == null);
    64 expect = false;
    65 addThis();
    68 function f4()
    69 {
    70   f1();
    71   f2();
    72   f3();
    73   return f4.arguments;
    74 }
    75 status = 'Section E of test';
    76 actual = (f4() == null);
    77 expect = false;
    78 addThis();
    80 status = 'Section F of test';
    81 actual = (f4(0) == null);
    82 expect = false;
    83 addThis();
    86 function f5()
    87 {
    88   if (cnRecurse)
    89   {
    90     cnRecurse = false;
    91     f5();
    92   }
    93   return f5.arguments;
    94 }
    95 status = 'Section G of test';
    96 actual = (f5() == null);
    97 expect = false;
    98 addThis();
   100 status = 'Section H of test';
   101 actual = (f5(0) == null);
   102 expect = false;
   103 addThis();
   107 //-------------------------------------------------------------------------------------------------
   108 test();
   109 //-------------------------------------------------------------------------------------------------
   112 function addThis()
   113 {
   114   statusitems[UBound] = status;
   115   actualvalues[UBound] = isThisNull(actual);
   116   expectedvalues[UBound] = isThisNull(expect);
   117   UBound++;
   118 }
   121 function test()
   122 {
   123   enterFunc ('test');
   124   printBugNumber(BUGNUMBER);
   125   printStatus (summary);
   127   for (var i = 0; i < UBound; i++)
   128   {
   129     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   130   }
   132   exitFunc ('test');
   133 }
   136 function isThisNull(bool)
   137 {
   138   return bool? cnNull : cnNonNull
   139     }

mercurial