js/src/tests/js1_5/Expressions/regress-96526-noargsub.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  *
     8  * Date:    29 Oct 2002
     9  * SUMMARY: Testing "use" and "set" operations on expressions like a[i][j][k]
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=96526#c52
    11  *
    12  * Brendan: "The idea is to cover all the 'use' and 'set' (as in modify)
    13  * operations you can do on an expression like a[i][j][k], including variations
    14  * where you replace |a| with arguments (literally) and |i| with 0, 1, 2, etc.
    15  * (to hit the optimization for arguments[0]... that uses JSOP_ARGSUB)."
    16  */
    17 //-----------------------------------------------------------------------------
    18 var UBound = 0;
    19 var BUGNUMBER = 96526;
    20 var summary = 'Testing "use" and "set" ops on expressions like a[i][j][k]';
    21 var status = '';
    22 var statusitems = [];
    23 var actual = '';
    24 var actualvalues = [];
    25 var expect= '';
    26 var expectedvalues = [];
    28 var z='magic';
    29 Number.prototype.magic=42;
    31 status = inSection(1);
    32 actual = f(2,1,[-1,0,[1,2,[3,4]]]);
    33 expect = 42;
    34 addThis();
    37 function f(j,k,a)
    38 {
    39   status = inSection(2);
    40   actual = formatArray(a[2]);
    41   expect = formatArray([1,2,[3,4]]);
    42   addThis();
    44   status = inSection(3);
    45   actual = formatArray(a[2][j]);
    46   expect = formatArray([3,4]);
    47   addThis();
    49   status = inSection(4);
    50   actual = a[2][j][k];
    51   expect = 4;
    52   addThis();
    54   status = inSection(5);
    55   actual = a[2][j][k][z];
    56   expect = 42;
    57   addThis();
    59   return a[2][j][k][z];
    60 }
    64 //-----------------------------------------------------------------------------
    65 test();
    66 //-----------------------------------------------------------------------------
    70 function addThis()
    71 {
    72   statusitems[UBound] = status;
    73   actualvalues[UBound] = actual;
    74   expectedvalues[UBound] = expect;
    75   UBound++;
    76 }
    79 function test()
    80 {
    81   enterFunc('test');
    82   printBugNumber(BUGNUMBER);
    83   printStatus(summary);
    85   for (var i=0; i<UBound; i++)
    86   {
    87     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    88   }
    90   exitFunc ('test');
    91 }

mercurial