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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_3/Function/regress-85880.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,139 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * Date: 2001-06-14
    1.11 + *
    1.12 + * SUMMARY: Regression test for Bugzilla bug 85880
    1.13 + *
    1.14 + * Rhino interpreted mode was nulling out the arguments object of a
    1.15 + * function if it happened to call another function inside its body.
    1.16 + *
    1.17 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=85880
    1.18 + *
    1.19 + */
    1.20 +//-----------------------------------------------------------------------------
    1.21 +var UBound = 0;
    1.22 +var BUGNUMBER = 85880;
    1.23 +var summary = 'Arguments object of g(){f()} should not be null';
    1.24 +var cnNonNull = 'Arguments != null';
    1.25 +var cnNull = 'Arguments == null';
    1.26 +var cnRecurse = true;
    1.27 +var status = '';
    1.28 +var statusitems = [];
    1.29 +var actual = '';
    1.30 +var actualvalues = [];
    1.31 +var expect= '';
    1.32 +var expectedvalues = [];
    1.33 +
    1.34 +
    1.35 +function f1(x)
    1.36 +{
    1.37 +}
    1.38 +
    1.39 +
    1.40 +function f2()
    1.41 +{
    1.42 +  return f2.arguments;
    1.43 +}
    1.44 +status = 'Section A of test';
    1.45 +actual = (f2() == null);
    1.46 +expect = false;
    1.47 +addThis();
    1.48 +
    1.49 +status = 'Section B of test';
    1.50 +actual = (f2(0) == null);
    1.51 +expect = false;
    1.52 +addThis();
    1.53 +
    1.54 +
    1.55 +function f3()
    1.56 +{
    1.57 +  f1();
    1.58 +  return f3.arguments;
    1.59 +}
    1.60 +status = 'Section C of test';
    1.61 +actual = (f3() == null);
    1.62 +expect = false;
    1.63 +addThis();
    1.64 +
    1.65 +status = 'Section D of test';
    1.66 +actual = (f3(0) == null);
    1.67 +expect = false;
    1.68 +addThis();
    1.69 +
    1.70 +
    1.71 +function f4()
    1.72 +{
    1.73 +  f1();
    1.74 +  f2();
    1.75 +  f3();
    1.76 +  return f4.arguments;
    1.77 +}
    1.78 +status = 'Section E of test';
    1.79 +actual = (f4() == null);
    1.80 +expect = false;
    1.81 +addThis();
    1.82 +
    1.83 +status = 'Section F of test';
    1.84 +actual = (f4(0) == null);
    1.85 +expect = false;
    1.86 +addThis();
    1.87 +
    1.88 +
    1.89 +function f5()
    1.90 +{
    1.91 +  if (cnRecurse)
    1.92 +  {
    1.93 +    cnRecurse = false;
    1.94 +    f5();
    1.95 +  }
    1.96 +  return f5.arguments;
    1.97 +}
    1.98 +status = 'Section G of test';
    1.99 +actual = (f5() == null);
   1.100 +expect = false;
   1.101 +addThis();
   1.102 +
   1.103 +status = 'Section H of test';
   1.104 +actual = (f5(0) == null);
   1.105 +expect = false;
   1.106 +addThis();
   1.107 +
   1.108 +
   1.109 +
   1.110 +//-------------------------------------------------------------------------------------------------
   1.111 +test();
   1.112 +//-------------------------------------------------------------------------------------------------
   1.113 +
   1.114 +
   1.115 +function addThis()
   1.116 +{
   1.117 +  statusitems[UBound] = status;
   1.118 +  actualvalues[UBound] = isThisNull(actual);
   1.119 +  expectedvalues[UBound] = isThisNull(expect);
   1.120 +  UBound++;
   1.121 +}
   1.122 +
   1.123 +
   1.124 +function test()
   1.125 +{
   1.126 +  enterFunc ('test');
   1.127 +  printBugNumber(BUGNUMBER);
   1.128 +  printStatus (summary);
   1.129 +
   1.130 +  for (var i = 0; i < UBound; i++)
   1.131 +  {
   1.132 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   1.133 +  }
   1.134 +
   1.135 +  exitFunc ('test');
   1.136 +}
   1.137 +
   1.138 +
   1.139 +function isThisNull(bool)
   1.140 +{
   1.141 +  return bool? cnNull : cnNonNull
   1.142 +    }

mercurial