js/src/tests/js1_5/Expressions/regress-96526-noargsub.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:2384138e1148
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/. */
5
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 = [];
27
28 var z='magic';
29 Number.prototype.magic=42;
30
31 status = inSection(1);
32 actual = f(2,1,[-1,0,[1,2,[3,4]]]);
33 expect = 42;
34 addThis();
35
36
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();
43
44 status = inSection(3);
45 actual = formatArray(a[2][j]);
46 expect = formatArray([3,4]);
47 addThis();
48
49 status = inSection(4);
50 actual = a[2][j][k];
51 expect = 4;
52 addThis();
53
54 status = inSection(5);
55 actual = a[2][j][k][z];
56 expect = 42;
57 addThis();
58
59 return a[2][j][k][z];
60 }
61
62
63
64 //-----------------------------------------------------------------------------
65 test();
66 //-----------------------------------------------------------------------------
67
68
69
70 function addThis()
71 {
72 statusitems[UBound] = status;
73 actualvalues[UBound] = actual;
74 expectedvalues[UBound] = expect;
75 UBound++;
76 }
77
78
79 function test()
80 {
81 enterFunc('test');
82 printBugNumber(BUGNUMBER);
83 printStatus(summary);
84
85 for (var i=0; i<UBound; i++)
86 {
87 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
88 }
89
90 exitFunc ('test');
91 }

mercurial