Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: mozilla-tests/js1_5/Array/regress-465980-02.js

Issue 2865028: Update the mozilla tests to new version (as of 2010-06-29). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
4 *
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/
9 *
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.
14 *
15 * The Original Code is JavaScript Engine testing utilities.
16 *
17 * The Initial Developer of the Original Code is
18 * Mozilla Foundation.
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s): Jeff Walden
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 var gTestfile = 'regress-465980-02.js';
39 //-----------------------------------------------------------------------------
40 var BUGNUMBER = 465980;
41 var summary = 'Do not crash @ InitArrayElements';
42 var actual = '';
43 var expect = '';
44
45
46 //-----------------------------------------------------------------------------
47 test();
48 //-----------------------------------------------------------------------------
49
50 function test()
51 {
52 enterFunc ('test');
53 printBugNumber(BUGNUMBER);
54 printStatus (summary);
55
56 function describe(name, startLength, pushArgs, expectThrow, expectLength)
57 {
58 return name + "(" + startLength + ", " +
59 "[" + pushArgs.join(", ") + "], " +
60 expectThrow + ", " +
61 expectLength + ")";
62 }
63
64 var push = Array.prototype.push;
65 var unshift = Array.prototype.unshift;
66
67 function testArrayPush(startLength, pushArgs, expectThrow, expectLength)
68 {
69 print("running testArrayPush(" +
70 startLength + ", " +
71 "[" + pushArgs.join(", ") + "], " +
72 expectThrow + ", " +
73 expectLength + ")...");
74 var a = new Array(startLength);
75 try
76 {
77 push.apply(a, pushArgs);
78 if (expectThrow)
79 {
80 throw "expected to throw for " +
81 describe("testArrayPush", startLength, pushArgs, expectThrow,
82 expectLength);
83 }
84 }
85 catch (e)
86 {
87 if (!(e instanceof RangeError))
88 {
89 throw "unexpected exception type thrown: " + e + " for " +
90 describe("testArrayPush", startLength, pushArgs, expectThrow,
91 expectLength);
92 }
93 if (!expectThrow)
94 {
95 throw "unexpected exception " + e + " for " +
96 describe("testArrayPush", startLength, pushArgs, expectThrow,
97 expectLength);
98 }
99 }
100
101 if (a.length !== expectLength)
102 {
103 throw "unexpected modified-array length for " +
104 describe("testArrayPush", startLength, pushArgs, expectThrow,
105 expectLength);
106 }
107
108 for (var i = 0, sz = pushArgs.length; i < sz; i++)
109 {
110 var index = i + startLength;
111 if (a[index] !== pushArgs[i])
112 {
113 throw "unexpected value " + a[index] +
114 " at index " + index + " (" + i + ") during " +
115 describe("testArrayPush", startLength, pushArgs, expectThrow,
116 expectLength) + ", expected " + pushArgs[i];
117 }
118 }
119 }
120
121 function testArrayUnshift(startLength, unshiftArgs, expectThrow, expectLength)
122 {
123 print("running testArrayUnshift(" +
124 startLength + ", " +
125 "[" + unshiftArgs.join(", ") + "], " +
126 expectThrow + ", " +
127 expectLength + ")...");
128 var a = new Array(startLength);
129 try
130 {
131 unshift.apply(a, unshiftArgs);
132 if (expectThrow)
133 {
134 throw "expected to throw for " +
135 describe("testArrayUnshift", startLength, unshiftArgs, expectThrow,
136 expectLength);
137 }
138 }
139 catch (e)
140 {
141 if (!(e instanceof RangeError))
142 {
143 throw "unexpected exception type thrown: " + e + " for " +
144 describe("testArrayUnshift", startLength, unshiftArgs, expectThrow,
145 expectLength);
146 }
147 if (!expectThrow)
148 {
149 throw "unexpected exception " + e + " for " +
150 describe("testArrayUnshift", startLength, unshiftArgs, expectThrow,
151 expectLength);
152 }
153 }
154
155 if (a.length !== expectLength)
156 {
157 throw "unexpected modified-array length for " +
158 describe("testArrayUnshift", startLength, unshiftArgs, expectThrow,
159 expectLength);
160 }
161
162 for (var i = 0, sz = unshiftArgs.length; i < sz; i++)
163 {
164 if (a[i] !== unshiftArgs[i])
165 {
166 throw "unexpected value at index " + index + " during " +
167 describe("testArrayUnshift", startLength, unshiftArgs, expectThrow,
168 expectLength);
169 }
170 }
171 }
172
173 var failed = true;
174
175 try
176 {
177 var foo = "foo", bar = "bar", baz = "baz";
178
179 testArrayPush(4294967294, [foo], false, 4294967295);
180 testArrayPush(4294967294, [foo, bar], true, 4294967295);
181 testArrayPush(4294967294, [foo, bar, baz], true, 4294967295);
182 testArrayPush(4294967295, [foo], true, 4294967295);
183 testArrayPush(4294967295, [foo, bar], true, 4294967295);
184 testArrayPush(4294967295, [foo, bar, baz], true, 4294967295);
185
186 testArrayUnshift(4294967294, [foo], false, 4294967295);
187 testArrayUnshift(4294967294, [foo, bar], true, 4294967294);
188 testArrayUnshift(4294967294, [foo, bar, baz], true, 4294967294);
189 testArrayUnshift(4294967295, [foo], true, 4294967295);
190 testArrayUnshift(4294967295, [foo, bar], true, 4294967295);
191 testArrayUnshift(4294967295, [foo, bar, baz], true, 4294967295);
192
193 }
194 catch (e)
195 {
196 actual = e + '';
197 }
198
199 reportCompare(expect, actual, summary);
200
201 exitFunc ('test');
202 }
OLDNEW
« no previous file with comments | « mozilla-tests/js1_5/Array/regress-465980-01.js ('k') | mozilla-tests/js1_5/Array/regress-474529.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698