Bug 1921963 part 1 - Use JS::ReportUncatchableException more outside the JS engine...
[gecko.git] / js / src / tests / non262 / expressions / regress-96526-delelem.js
blobb1fb73836febeb7338a939907e4fbcd75aca7a88
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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;
30 f(2,1,[-1,0,[1,2,[3,4]]]);
32 function f(j,k,a)
34   status = inSection(1);
35   actual = formatArray(a[2]);
36   expect = formatArray([1,2,[3,4]]);
37   addThis();
39   status = inSection(2);
40   actual = formatArray(a[2][j]);
41   expect = formatArray([3,4]);
42   addThis();
44   status = inSection(3);
45   actual = a[2][j][k];
46   expect = 4;
47   addThis();
49   status = inSection(4);
50   actual = a[2][j][k][z];
51   expect = 42;
52   addThis();
54   delete a[2][j][k];
56   status = inSection(5);
57   actual = formatArray(a[2][j]);
58   expect = formatArray([3, ,]);
59   addThis();
64 //-----------------------------------------------------------------------------
65 test();
66 //-----------------------------------------------------------------------------
70 function addThis()
72   statusitems[UBound] = status;
73   actualvalues[UBound] = actual;
74   expectedvalues[UBound] = expect;
75   UBound++;
79 function test()
81   printBugNumber(BUGNUMBER);
82   printStatus(summary);
84   for (var i=0; i<UBound; i++)
85   {
86     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
87   }