1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Expressions/regress-96526-delelem.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 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 + * 1.11 + * Date: 29 Oct 2002 1.12 + * SUMMARY: Testing "use" and "set" operations on expressions like a[i][j][k] 1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=96526#c52 1.14 + * 1.15 + * Brendan: "The idea is to cover all the 'use' and 'set' (as in modify) 1.16 + * operations you can do on an expression like a[i][j][k], including variations 1.17 + * where you replace |a| with arguments (literally) and |i| with 0, 1, 2, etc. 1.18 + * (to hit the optimization for arguments[0]... that uses JSOP_ARGSUB)." 1.19 + */ 1.20 +//----------------------------------------------------------------------------- 1.21 +var UBound = 0; 1.22 +var BUGNUMBER = 96526; 1.23 +var summary = 'Testing "use" and "set" ops on expressions like a[i][j][k]'; 1.24 +var status = ''; 1.25 +var statusitems = []; 1.26 +var actual = ''; 1.27 +var actualvalues = []; 1.28 +var expect= ''; 1.29 +var expectedvalues = []; 1.30 + 1.31 +var z='magic'; 1.32 +Number.prototype.magic=42; 1.33 +f(2,1,[-1,0,[1,2,[3,4]]]); 1.34 + 1.35 +function f(j,k,a) 1.36 +{ 1.37 + status = inSection(1); 1.38 + actual = formatArray(a[2]); 1.39 + expect = formatArray([1,2,[3,4]]); 1.40 + addThis(); 1.41 + 1.42 + status = inSection(2); 1.43 + actual = formatArray(a[2][j]); 1.44 + expect = formatArray([3,4]); 1.45 + addThis(); 1.46 + 1.47 + status = inSection(3); 1.48 + actual = a[2][j][k]; 1.49 + expect = 4; 1.50 + addThis(); 1.51 + 1.52 + status = inSection(4); 1.53 + actual = a[2][j][k][z]; 1.54 + expect = 42; 1.55 + addThis(); 1.56 + 1.57 + delete a[2][j][k]; 1.58 + 1.59 + status = inSection(5); 1.60 + actual = formatArray(a[2][j]); 1.61 + expect = '[3, ,]'; 1.62 + addThis(); 1.63 +} 1.64 + 1.65 + 1.66 + 1.67 +//----------------------------------------------------------------------------- 1.68 +test(); 1.69 +//----------------------------------------------------------------------------- 1.70 + 1.71 + 1.72 + 1.73 +function addThis() 1.74 +{ 1.75 + statusitems[UBound] = status; 1.76 + actualvalues[UBound] = actual; 1.77 + expectedvalues[UBound] = expect; 1.78 + UBound++; 1.79 +} 1.80 + 1.81 + 1.82 +function test() 1.83 +{ 1.84 + enterFunc('test'); 1.85 + printBugNumber(BUGNUMBER); 1.86 + printStatus(summary); 1.87 + 1.88 + for (var i=0; i<UBound; i++) 1.89 + { 1.90 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.91 + } 1.92 + 1.93 + exitFunc ('test'); 1.94 +}