Debian Codegraph @

rhino/testsrc/tests/js1_5/Expressions/regress-96526-noargsub.js

raw symbols SCIP
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 gTestfile = 'regress-96526-noargsub.js';
19 var UBound = 0;
20 var BUGNUMBER = 96526;
21 var summary = 'Testing "use" and "set" ops on expressions like a[i][j][k]';
22 var status = '';
23 var statusitems = [];
24 var actual = '';
25 var actualvalues = [];
26 var expect= '';
27 var expectedvalues = [];
28
29 var z='magic';
30 Number.prototype.magic=42;
31
32 status = inSection(1);
33 actual = f(2,1,[-1,0,[1,2,[3,4]]]);
34 expect = 42;
35 addThis();
36
37
38 function f(j,k,a)
39 {
40 status = inSection(2);
41 actual = formatArray(a[2]);
42 expect = formatArray([1,2,[3,4]]);
43 addThis();
44
45 status = inSection(3);
46 actual = formatArray(a[2][j]);
47 expect = formatArray([3,4]);
48 addThis();
49
50 status = inSection(4);
51 actual = a[2][j][k];
52 expect = 4;
53 addThis();
54
55 status = inSection(5);
56 actual = a[2][j][k][z];
57 expect = 42;
58 addThis();
59
60 return a[2][j][k][z];
61 }
62
63
64
65 //-----------------------------------------------------------------------------
66 test();
67 //-----------------------------------------------------------------------------
68
69
70
71 function addThis()
72 {
73 statusitems[UBound] = status;
74 actualvalues[UBound] = actual;
75 expectedvalues[UBound] = expect;
76 UBound++;
77 }
78
79
80 function test()
81 {
82 enterFunc('test');
83 printBugNumber(BUGNUMBER);
84 printStatus(summary);
85
86 for (var i=0; i<UBound; i++)
87 {
88 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
89 }
90
91 exitFunc ('test');
92 }