Bug 469739 - Add support for displaying Vista UAC shield icon; r=joe sr=vladimir
[wine-gecko.git] / js / tests / js1_5 / Array / regress-178722.js
blobe34f830b270abb1f47ac4a4c0f7d3d8e74d0f880
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is JavaScript Engine testing utilities.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corp.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * pschwartau@netscape.com
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 * Date: 06 November 2002
42 * SUMMARY: arr.sort() should not output |undefined| when |arr| is empty
43 * See http://bugzilla.mozilla.org/show_bug.cgi?id=178722
45 * ECMA-262 Ed.3: 15.4.4.11 Array.prototype.sort (comparefn)
47 * 1. Call the [[Get]] method of this object with argument "length".
48 * 2. Call ToUint32(Result(1)).
49 * 3. Perform an implementation-dependent sequence of calls to the [[Get]],
50 * [[Put]], and [[Delete]] methods of this object, etc. etc.
51 * 4. Return this object.
54 * Note that sort() is done in-place on |arr|. In other words, sort() is a
55 * "destructive" method rather than a "functional" method. The return value
56 * of |arr.sort()| and |arr| are the same object.
58 * If |arr| is an empty array, the return value of |arr.sort()| should be
59 * an empty array, not the value |undefined| as was occurring in bug 178722.
62 //-----------------------------------------------------------------------------
63 var gTestfile = 'regress-178722.js';
64 var UBound = 0;
65 var BUGNUMBER = 178722;
66 var summary = 'arr.sort() should not output |undefined| when |arr| is empty';
67 var status = '';
68 var statusitems = [];
69 var actual = '';
70 var actualvalues = [];
71 var expect= '';
72 var expectedvalues = [];
73 var arr;
76 // create empty array or pseudo-array objects in various ways
77 var arr1 = Array();
78 var arr2 = new Array();
79 var arr3 = [];
80 var arr4 = [1];
81 arr4.pop();
84 status = inSection(1);
85 arr = arr1.sort();
86 actual = arr instanceof Array && arr.length === 0 && arr === arr1;
87 expect = true;
88 addThis();
90 status = inSection(2);
91 arr = arr2.sort();
92 actual = arr instanceof Array && arr.length === 0 && arr === arr2;
93 expect = true;
94 addThis();
96 status = inSection(3);
97 arr = arr3.sort();
98 actual = arr instanceof Array && arr.length === 0 && arr === arr3;
99 expect = true;
100 addThis();
102 status = inSection(4);
103 arr = arr4.sort();
104 actual = arr instanceof Array && arr.length === 0 && arr === arr4;
105 expect = true;
106 addThis();
108 // now do the same thing, with non-default sorting:
109 function g() {return 1;}
111 status = inSection('1a');
112 arr = arr1.sort(g);
113 actual = arr instanceof Array && arr.length === 0 && arr === arr1;
114 expect = true;
115 addThis();
117 status = inSection('2a');
118 arr = arr2.sort(g);
119 actual = arr instanceof Array && arr.length === 0 && arr === arr2;
120 expect = true;
121 addThis();
123 status = inSection('3a');
124 arr = arr3.sort(g);
125 actual = arr instanceof Array && arr.length === 0 && arr === arr3;
126 expect = true;
127 addThis();
129 status = inSection('4a');
130 arr = arr4.sort(g);
131 actual = arr instanceof Array && arr.length === 0 && arr === arr4;
132 expect = true;
133 addThis();
137 //-----------------------------------------------------------------------------
138 test();
139 //-----------------------------------------------------------------------------
143 function addThis()
145 statusitems[UBound] = status;
146 actualvalues[UBound] = actual;
147 expectedvalues[UBound] = expect;
148 UBound++;
152 function test()
154 enterFunc('test');
155 printBugNumber(BUGNUMBER);
156 printStatus(summary);
158 for (var i=0; i<UBound; i++)
160 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
163 exitFunc ('test');