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

Side by Side Diff: mozilla-tests/js1_8_1/trace/math-trace-tests.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
« no previous file with comments | « mozilla-tests/js1_8_1/regress/shell.js ('k') | mozilla-tests/js1_8_1/trace/regress-451673.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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): Mike Shaver
23 * Brendan Eich
24 * Andreas Gal
25 * David Anderson
26 * Boris Zbarsky
27 * Brian Crowder
28 * Blake Kaplan
29 * Robert Sayre
30 * Vladimir Vukicevic
31 *
32 * Alternatively, the contents of this file may be used under the terms of
33 * either the GNU General Public License Version 2 or later (the "GPL"), or
34 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35 * in which case the provisions of the GPL or the LGPL are applicable instead
36 * of those above. If you wish to allow use of your version of this file only
37 * under the terms of either the GPL or the LGPL, and not to allow others to
38 * use your version of this file under the terms of the MPL, indicate your
39 * decision by deleting the provisions above and replace them with the notice
40 * and other provisions required by the GPL or the LGPL. If you do not delete
41 * the provisions above, a recipient may use your version of this file under
42 * the terms of any one of the MPL, the GPL or the LGPL.
43 *
44 * ***** END LICENSE BLOCK ***** */
45
46 var gTestfile = 'math-trace-tests.js';
47 //-----------------------------------------------------------------------------
48 var BUGNUMBER = 'none';
49 var summary = 'trace-capability math mini-testsuite';
50
51 printBugNumber(BUGNUMBER);
52 printStatus (summary);
53
54 jit(true);
55
56 /**
57 * A number of the tests in this file depend on the setting of
58 * HOTLOOP. Define some constants up front, so they're easy to grep
59 * for.
60 */
61 // The HOTLOOP constant we depend on; only readable from our stats
62 // object in debug builds.
63 const haveTracemonkey = !!(this.tracemonkey)
64 const HOTLOOP = haveTracemonkey ? tracemonkey.HOTLOOP : 2;
65 // The loop count at which we trace
66 const RECORDLOOP = HOTLOOP;
67 // The loop count at which we run the trace
68 const RUNLOOP = HOTLOOP + 1;
69
70 var testName = null;
71 if ("arguments" in this && arguments.length > 0)
72 testName = arguments[0];
73 var fails = [], passes=[];
74
75 function jitstatHandler(f)
76 {
77 if (!haveTracemonkey)
78 return;
79
80 // XXXbz this is a nasty hack, but I can't figure out a way to
81 // just use jitstats.tbl here
82 f("recorderStarted");
83 f("recorderAborted");
84 f("traceCompleted");
85 f("sideExitIntoInterpreter");
86 f("typeMapMismatchAtEntry");
87 f("returnToDifferentLoopHeader");
88 f("traceTriggered");
89 f("globalShapeMismatchAtEntry");
90 f("treesTrashed");
91 f("slotPromoted");
92 f("unstableLoopVariable");
93 f("noCompatInnerTrees");
94 f("breakLoopExits");
95 f("returnLoopExits");
96 }
97
98 function test(f)
99 {
100 if (!testName || testName == f.name) {
101 // Collect our jit stats
102 var localJITstats = {};
103 jitstatHandler(function(prop, local, global) {
104 localJITstats[prop] = tracemonkey[prop];
105 });
106 check(f.name, f(), f.expected, localJITstats, f.jitstats);
107 }
108 }
109
110 function map_test(t, cases)
111 {
112 for (var i = 0; i < cases.length; i++) {
113 function c() { return t(cases[i].input); }
114 c.expected = cases[i].expected;
115 c.name = t.name + "(" + uneval(cases[i].input) + ")";
116 test(c);
117 }
118 }
119
120 // Use this function to compare expected and actual test results.
121 // Types must match.
122 // For numbers, treat NaN as matching NaN, distinguish 0 and -0, and
123 // tolerate a certain degree of error for other values.
124 //
125 // These are the same criteria used by the tests in js/tests, except that
126 // we distinguish 0 and -0.
127 function close_enough(expected, actual)
128 {
129 if (typeof expected != typeof actual)
130 return false;
131 if (typeof expected != 'number')
132 return actual == expected;
133
134 // Distinguish NaN from other values. Using x != x comparisons here
135 // works even if tests redefine isNaN.
136 if (actual != actual)
137 return expected != expected
138 if (expected != expected)
139 return false;
140
141 // Tolerate a certain degree of error.
142 if (actual != expected)
143 return Math.abs(actual - expected) <= 1E-10;
144
145 // Distinguish 0 and -0.
146 if (actual == 0)
147 return (1 / actual > 0) == (1 / expected > 0);
148
149 return true;
150 }
151
152 function check(desc, actual, expected, oldJITstats, expectedJITstats)
153 {
154 var pass = false;
155 if (close_enough(expected, actual)) {
156 pass = true;
157 jitstatHandler(function(prop) {
158 if (expectedJITstats && prop in expectedJITstats &&
159 expectedJITstats[prop] !=
160 tracemonkey[prop] - oldJITstats[prop]) {
161 pass = false;
162 }
163 });
164 if (pass) {
165 reportCompare(expected, actual, desc);
166 passes.push(desc);
167 return print(desc, ": passed");
168 }
169 }
170
171 if (expected instanceof RegExp) {
172 pass = reportMatch(expected, actual + '', desc);
173 if (pass) {
174 jitstatHandler(function(prop) {
175 if (expectedJITstats && prop in expectedJITstats &&
176 expectedJITstats[prop] !=
177 tracemonkey[prop] - oldJITstats[prop]) {
178 pass = false;
179 }
180 });
181 }
182 if (pass) {
183 passes.push(desc);
184 return print(desc, ": passed");
185 }
186 }
187
188 reportCompare(expected, actual, desc);
189
190 fails.push(desc);
191 var expectedStats = "";
192 if (expectedJITstats) {
193 jitstatHandler(function(prop) {
194 if (prop in expectedJITstats) {
195 if (expectedStats)
196 expectedStats += " ";
197 expectedStats +=
198 prop + ": " + expectedJITstats[prop];
199 }
200 });
201 }
202 var actualStats = "";
203 if (expectedJITstats) {
204 jitstatHandler(function(prop) {
205 if (prop in expectedJITstats) {
206 if (actualStats)
207 actualStats += " ";
208 actualStats += prop + ": " + (tracemonkey[prop]-oldJITstats[prop]);
209 }
210 });
211 }
212 print(desc, ": FAILED: expected", typeof(expected),
213 "(", uneval(expected), ")",
214 (expectedStats ? " [" + expectedStats + "] " : ""),
215 "!= actual",
216 typeof(actual), "(", uneval(actual), ")",
217 (actualStats ? " [" + actualStats + "] " : ""));
218 }
219
220 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
221
222 // Apply FUNCNAME to ARGS, and check against EXPECTED.
223 // Expect a loop containing such a call to be traced.
224 // FUNCNAME and ARGS are both strings.
225 // ARGS has the form of an argument list: a comma-separated list of expressions.
226 // Certain Tracemonkey limitations require us to pass FUNCNAME as a string.
227 // Passing ARGS as a string allows us to assign better test names:
228 // expressions like Math.PI/4 haven't been evaluated to big hairy numbers.
229 function testmath(funcname, args, expected) {
230 var i, j;
231
232 var arg_value_list = eval("[" + args + "]");
233 var arity = arg_value_list.length;
234
235 // Build the string "a[i][0],...,a[i][ARITY-1]".
236 var actuals = []
237 for (i = 0; i < arity; i++)
238 actuals.push("a[i][" + i + "]");
239 actuals = actuals.join(",");
240
241 // Create a function that maps FUNCNAME across an array of input values.
242 // Unless we eval here, the call to funcname won't get traced.
243 // FUNCNAME="Infinity/Math.abs" and cases like that happen to
244 // parse, too, in a twisted way.
245 var mapfunc = eval("(function(a) {\n"
246 + " for (var i = 0; i < a.length; i++)\n"
247 + " a[i] = " + funcname + "(" + actuals +");\n"
248 + " })\n");
249
250 // To prevent the compiler from doing constant folding, produce an
251 // array to pass to mapfunc that contains enough dummy
252 // values at the front to get the loop body jitted, and then our
253 // actual test value.
254 var dummies_and_input = [];
255 for (i = 0; i < RUNLOOP; i++) {
256 var dummy_list = [];
257 for (j = 0; j < arity; j++)
258 dummy_list[j] = .0078125 * ((i + j) % 128);
259 dummies_and_input[i] = dummy_list;
260 }
261 dummies_and_input[RUNLOOP] = arg_value_list;
262
263 function testfunc() {
264 // Map the function across the dummy values and the test input.
265 mapfunc(dummies_and_input);
266 return dummies_and_input[RUNLOOP];
267 }
268 testfunc.name = funcname + "(" + args + ")";
269 testfunc.expected = expected;
270
271 // Disable jitstats check. This never worked right. The actual part of the
272 // loop we cared about was never traced. We traced the filler parts early
273 // and then took a mismatch side exit on every subequent array read with
274 // a different type (gal, discovered when fixing bug 479110).
275 // testfunc.jitstats = {
276 // recorderStarted: 1,
277 // recorderAborted: 0,
278 // traceTriggered: 1
279 // };
280
281 test(testfunc);
282 }
283
284 testmath("Math.abs", "void 0", Number.NaN)
285 testmath("Math.abs", "null", 0)
286 testmath("Math.abs", "true", 1)
287 testmath("Math.abs", "false", 0)
288 testmath("Math.abs", "\"a string primitive\"", Number.NaN)
289 testmath("Math.abs", "new String( 'a String object' )", Number.NaN)
290 testmath("Math.abs", "Number.NaN", Number.NaN)
291 testmath("Math.abs", "0", 0)
292 testmath("Math.abs", "-0", 0)
293 testmath("Infinity/Math.abs", "-0", Infinity)
294 testmath("Math.abs", "Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
295 testmath("Math.abs", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
296 testmath("Math.abs", "- Number.MAX_VALUE", Number.MAX_VALUE)
297 testmath("Math.abs", "-Number.MIN_VALUE", Number.MIN_VALUE)
298 testmath("Math.abs", "Number.MAX_VALUE", Number.MAX_VALUE)
299 testmath("Math.abs", "Number.MIN_VALUE", Number.MIN_VALUE)
300 testmath("Math.abs", "-1", 1)
301 testmath("Math.abs", "new Number(-1)", 1)
302 testmath("Math.abs", "1", 1)
303 testmath("Math.abs", "Math.PI", Math.PI)
304 testmath("Math.abs", "-Math.PI", Math.PI)
305 testmath("Math.abs", "-1/100000000", 1/100000000)
306 testmath("Math.abs", "-Math.pow(2,32)", Math.pow(2,32))
307 testmath("Math.abs", "Math.pow(2,32)", Math.pow(2,32))
308 testmath("Math.abs", "-0xfff", 4095)
309 testmath("Math.abs", "-0777", 511)
310 testmath("Math.abs", "'-1e-1'", 0.1)
311 testmath("Math.abs", "'0xff'", 255)
312 testmath("Math.abs", "'077'", 77)
313 testmath("Math.abs", "'Infinity'", Infinity)
314 testmath("Math.abs", "'-Infinity'", Infinity)
315
316 testmath("Math.acos", "void 0", Number.NaN)
317 testmath("Math.acos", "null", Math.PI/2)
318 testmath("Math.acos", "Number.NaN", Number.NaN)
319 testmath("Math.acos", "\"a string\"", Number.NaN)
320 testmath("Math.acos", "'0'", Math.PI/2)
321 testmath("Math.acos", "'1'", 0)
322 testmath("Math.acos", "'-1'", Math.PI)
323 testmath("Math.acos", "1.00000001", Number.NaN)
324 testmath("Math.acos", "-1.00000001", Number.NaN)
325 testmath("Math.acos", "1", 0)
326 testmath("Math.acos", "-1", Math.PI)
327 testmath("Math.acos", "0", Math.PI/2)
328 testmath("Math.acos", "-0", Math.PI/2)
329 testmath("Math.acos", "Math.SQRT1_2", Math.PI/4)
330 testmath("Math.acos", "-Math.SQRT1_2", Math.PI/4*3)
331 testmath("Math.acos", "0.9999619230642", Math.PI/360)
332 testmath("Math.acos", "-3.0", Number.NaN)
333
334 testmath("Math.asin", "void 0", Number.NaN)
335 testmath("Math.asin", "null", 0)
336 testmath("Math.asin", "Number.NaN", Number.NaN)
337 testmath("Math.asin", "\"string\"", Number.NaN)
338 testmath("Math.asin", "\"0\"", 0)
339 testmath("Math.asin", "\"1\"", Math.PI/2)
340 testmath("Math.asin", "\"-1\"", -Math.PI/2)
341 testmath("Math.asin", "Math.SQRT1_2+''", Math.PI/4)
342 testmath("Math.asin", "-Math.SQRT1_2+''", -Math.PI/4)
343 testmath("Math.asin", "1.000001", Number.NaN)
344 testmath("Math.asin", "-1.000001", Number.NaN)
345 testmath("Math.asin", "0", 0)
346 testmath("Math.asin", "-0", -0)
347 testmath("Infinity/Math.asin", "-0", -Infinity)
348 testmath("Math.asin", "1", Math.PI/2)
349 testmath("Math.asin", "-1", -Math.PI/2)
350 testmath("Math.asin", "Math.SQRT1_2", Math.PI/4)
351 testmath("Math.asin", "-Math.SQRT1_2", -Math.PI/4)
352
353 testmath("Math.atan", "void 0", Number.NaN)
354 testmath("Math.atan", "null", 0)
355 testmath("Math.atan", "Number.NaN", Number.NaN)
356 testmath("Math.atan", "\"a string\"", Number.NaN)
357 testmath("Math.atan", "'0'", 0)
358 testmath("Math.atan", "'1'", Math.PI/4)
359 testmath("Math.atan", "'-1'", -Math.PI/4)
360 testmath("Math.atan", "'Infinity'", Math.PI/2)
361 testmath("Math.atan", "'-Infinity'", -Math.PI/2)
362 testmath("Math.atan", "0", 0)
363 testmath("Math.atan", "-0", -0)
364 testmath("Infinity/Math.atan", "-0", -Infinity)
365 testmath("Math.atan", "Number.POSITIVE_INFINITY", Math.PI/2)
366 testmath("Math.atan", "Number.NEGATIVE_INFINITY", -Math.PI/2)
367 testmath("Math.atan", "1", Math.PI/4)
368 testmath("Math.atan", "-1", -Math.PI/4)
369
370 testmath("Math.atan2", "Number.NaN,0", Number.NaN)
371 testmath("Math.atan2", "null, null", 0)
372 testmath("Math.atan2", "void 0, void 0", Number.NaN)
373 testmath("Math.atan2", "0,Number.NaN", Number.NaN)
374 testmath("Math.atan2", "1,0", Math.PI/2)
375 testmath("Math.atan2", "1,-0", Math.PI/2)
376 testmath("Math.atan2", "0,0.001", 0)
377 testmath("Math.atan2", "0,0", 0)
378 testmath("Math.atan2", "0,-0", Math.PI)
379 testmath("Math.atan2", "0, -1", Math.PI)
380 testmath("Math.atan2", "-0, 1", -0)
381 testmath("Infinity/Math.atan2", "-0,1", -Infinity)
382 testmath("Math.atan2", "-0,0", -0)
383 testmath("Math.atan2", "-0, -0", -Math.PI)
384 testmath("Math.atan2", "-0, -1", -Math.PI)
385 testmath("Math.atan2", "-1, 0", -Math.PI/2)
386 testmath("Math.atan2", "-1, -0", -Math.PI/2)
387 testmath("Math.atan2", "1, Number.POSITIVE_INFINITY", 0)
388 testmath("Math.atan2", "1, Number.NEGATIVE_INFINITY", Math.PI)
389 testmath("Math.atan2", "-1,Number.POSITIVE_INFINITY", -0)
390 testmath("Infinity/Math.atan2", "-1,Infinity", -Infinity)
391 testmath("Math.atan2", "-1,Number.NEGATIVE_INFINITY", -Math.PI)
392 testmath("Math.atan2", "Number.POSITIVE_INFINITY, 0", Math.PI/2)
393 testmath("Math.atan2", "Number.POSITIVE_INFINITY, 1", Math.PI/2)
394 testmath("Math.atan2", "Number.POSITIVE_INFINITY,-1", Math.PI/2)
395 testmath("Math.atan2", "Number.POSITIVE_INFINITY,-0", Math.PI/2)
396 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 0", -Math.PI/2)
397 testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-0", -Math.PI/2)
398 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 1", -Math.PI/2)
399 testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-1", -Math.PI/2)
400 testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY", Mat h.PI/4)
401 testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY", 3*M ath.PI/4)
402 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", -Ma th.PI/4)
403 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", -3* Math.PI/4)
404 testmath("Math.atan2", "-1, 1", -Math.PI/4)
405
406 testmath("Math.ceil", "Number.NaN", Number.NaN)
407 testmath("Math.ceil", "null", 0)
408 testmath("Math.ceil", "void 0", Number.NaN)
409 testmath("Math.ceil", "'0'", 0)
410 testmath("Math.ceil", "'-0'", -0)
411 testmath("Infinity/Math.ceil", "'0'", Infinity)
412 testmath("Infinity/Math.ceil", "'-0'", -Infinity)
413 testmath("Math.ceil", "0", 0)
414 testmath("Math.ceil", "-0", -0)
415 testmath("Infinity/Math.ceil", "0", Infinity)
416 testmath("Infinity/Math.ceil", "-0", -Infinity)
417 testmath("Math.ceil", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
418 testmath("Math.ceil", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
419 testmath("Math.ceil", "-Number.MIN_VALUE", -0)
420 testmath("Infinity/Math.ceil", "-Number.MIN_VALUE", -Infinity)
421 testmath("Math.ceil", "1", 1)
422 testmath("Math.ceil", "-1", -1)
423 testmath("Math.ceil", "-0.9", -0)
424 testmath("Infinity/Math.ceil", "-0.9", -Infinity)
425 testmath("Math.ceil", "0.9", 1)
426 testmath("Math.ceil", "-1.1", -1)
427 testmath("Math.ceil", "1.1", 2)
428 testmath("Math.ceil", "Number.POSITIVE_INFINITY", -Math.floor(-Infinity))
429 testmath("Math.ceil", "Number.NEGATIVE_INFINITY", -Math.floor(Infinity))
430 testmath("Math.ceil", "-Number.MIN_VALUE", -Math.floor(Number.MIN_VALUE))
431 testmath("Math.ceil", "1", -Math.floor(-1))
432 testmath("Math.ceil", "-1", -Math.floor(1))
433 testmath("Math.ceil", "-0.9", -Math.floor(0.9))
434 testmath("Math.ceil", "0.9", -Math.floor(-0.9))
435 testmath("Math.ceil", "-1.1", -Math.floor(1.1))
436 testmath("Math.ceil", "1.1", -Math.floor(-1.1))
437
438 testmath("Math.cos", "void 0", Number.NaN)
439 testmath("Math.cos", "false", 1)
440 testmath("Math.cos", "null", 1)
441 testmath("Math.cos", "'0'", 1)
442 testmath("Math.cos", "\"Infinity\"", Number.NaN)
443 testmath("Math.cos", "'3.14159265359'", -1)
444 testmath("Math.cos", "Number.NaN", Number.NaN)
445 testmath("Math.cos", "0", 1)
446 testmath("Math.cos", "-0", 1)
447 testmath("Math.cos", "Number.POSITIVE_INFINITY", Number.NaN)
448 testmath("Math.cos", "Number.NEGATIVE_INFINITY", Number.NaN)
449 testmath("Math.cos", "0.7853981633974", 0.7071067811865)
450 testmath("Math.cos", "1.570796326795", 0)
451 testmath("Math.cos", "2.356194490192", -0.7071067811865)
452 testmath("Math.cos", "3.14159265359", -1)
453 testmath("Math.cos", "3.926990816987", -0.7071067811865)
454 testmath("Math.cos", "4.712388980385", 0)
455 testmath("Math.cos", "5.497787143782", 0.7071067811865)
456 testmath("Math.cos", "Math.PI*2", 1)
457 testmath("Math.cos", "Math.PI/4", Math.SQRT2/2)
458 testmath("Math.cos", "Math.PI/2", 0)
459 testmath("Math.cos", "3*Math.PI/4", -Math.SQRT2/2)
460 testmath("Math.cos", "Math.PI", -1)
461 testmath("Math.cos", "5*Math.PI/4", -Math.SQRT2/2)
462 testmath("Math.cos", "3*Math.PI/2", 0)
463 testmath("Math.cos", "7*Math.PI/4", Math.SQRT2/2)
464 testmath("Math.cos", "2*Math.PI", 1)
465 testmath("Math.cos", "-0.7853981633974", 0.7071067811865)
466 testmath("Math.cos", "-1.570796326795", 0)
467 testmath("Math.cos", "2.3561944901920", -.7071067811865)
468 testmath("Math.cos", "3.14159265359", -1)
469 testmath("Math.cos", "3.926990816987", -0.7071067811865)
470 testmath("Math.cos", "4.712388980385", 0)
471 testmath("Math.cos", "5.497787143782", 0.7071067811865)
472 testmath("Math.cos", "6.28318530718", 1)
473 testmath("Math.cos", "-Math.PI/4", Math.SQRT2/2)
474 testmath("Math.cos", "-Math.PI/2", 0)
475 testmath("Math.cos", "-3*Math.PI/4", -Math.SQRT2/2)
476 testmath("Math.cos", "-Math.PI", -1)
477 testmath("Math.cos", "-5*Math.PI/4", -Math.SQRT2/2)
478 testmath("Math.cos", "-3*Math.PI/2", 0)
479 testmath("Math.cos", "-7*Math.PI/4", Math.SQRT2/2)
480 testmath("Math.cos", "-Math.PI*2", 1)
481
482 testmath("Math.exp", "null", 1)
483 testmath("Math.exp", "void 0", Number.NaN)
484 testmath("Math.exp", "1", Math.E)
485 testmath("Math.exp", "true", Math.E)
486 testmath("Math.exp", "false", 1)
487 testmath("Math.exp", "'1'", Math.E)
488 testmath("Math.exp", "'0'", 1)
489 testmath("Math.exp", "Number.NaN", Number.NaN)
490 testmath("Math.exp", "0", 1)
491 testmath("Math.exp", "-0", 1)
492 testmath("Math.exp", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
493 testmath("Math.exp", "Number.NEGATIVE_INFINITY", 0)
494
495 testmath("Math.floor", "void 0", Number.NaN)
496 testmath("Math.floor", "null", 0)
497 testmath("Math.floor", "true", 1)
498 testmath("Math.floor", "false", 0)
499 testmath("Math.floor", "\"1.1\"", 1)
500 testmath("Math.floor", "\"-1.1\"", -2)
501 testmath("Math.floor", "\"0.1\"", 0)
502 testmath("Math.floor", "\"-0.1\"", -1)
503 testmath("Math.floor", "Number.NaN", Number.NaN)
504 testmath("Math.floor(Number.NaN) == -Math.ceil", "-Number.NaN", false)
505 testmath("Math.floor", "0", 0)
506 testmath("Math.floor(0) == -Math.ceil", "-0", true)
507 testmath("Math.floor", "-0", -0)
508 testmath("Infinity/Math.floor", "-0", -Infinity)
509 testmath("Math.floor(-0)== -Math.ceil", "0", true)
510 testmath("Math.floor", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
511 testmath("Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil", "Number.NEGATIVE_ INFINITY", true)
512 testmath("Math.floor", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
513 testmath("Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil", "Number.POSITIVE_ INFINITY", true)
514 testmath("Math.floor", "0.0000001", 0)
515 testmath("Math.floor(0.0000001)==-Math.ceil", "-0.0000001", true)
516 testmath("Math.floor", "-0.0000001", -1)
517 testmath("Math.floor(-0.0000001)==-Math.ceil", "0.0000001", true)
518
519 testmath("Math.log", "void 0", Number.NaN)
520 testmath("Math.log", "null", Number.NEGATIVE_INFINITY)
521 testmath("Math.log", "true", 0)
522 testmath("Math.log", "false", -Infinity)
523 testmath("Math.log", "'0'", -Infinity)
524 testmath("Math.log", "'1'", 0)
525 testmath("Math.log", "\"Infinity\"", Infinity)
526 testmath("Math.log", "Number.NaN", Number.NaN)
527 testmath("Math.log", "-0.000001", Number.NaN)
528 testmath("Math.log", "-1", Number.NaN)
529 testmath("Math.log", "0", Number.NEGATIVE_INFINITY)
530 testmath("Math.log", "-0", Number.NEGATIVE_INFINITY)
531 testmath("Math.log", "1", 0)
532 testmath("Math.log", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
533 testmath("Math.log", "Number.NEGATIVE_INFINITY", Number.NaN)
534
535 testmath("Math.max", "void 0, 1", Number.NaN)
536 testmath("Math.max", "void 0, void 0", Number.NaN)
537 testmath("Math.max", "null, 1", 1)
538 testmath("Math.max", "-1, null", 0)
539 testmath("Math.max", "true,false", 1)
540 testmath("Math.max", "\"-99\",\"99\"", 99)
541 testmath("Math.max", "Number.NaN,Number.POSITIVE_INFINITY", Number.NaN)
542 testmath("Math.max", "Number.NaN, 0", Number.NaN)
543 testmath("Math.max", "\"a string\", 0", Number.NaN)
544 testmath("Math.max", "Number.NaN,1", Number.NaN)
545 testmath("Math.max", "\"a string\", Number.POSITIVE_INFINITY", Number.NaN)
546 testmath("Math.max", "Number.POSITIVE_INFINITY, Number.NaN", Number.NaN)
547 testmath("Math.max", "Number.NaN, Number.NaN", Number.NaN)
548 testmath("Math.max", "0,Number.NaN", Number.NaN)
549 testmath("Math.max", "1, Number.NaN", Number.NaN)
550 testmath("Math.max", "0,0", 0)
551 testmath("Math.max", "0,-0", 0)
552 testmath("Math.max", "-0,0", 0)
553 testmath("Math.max", "-0,-0", -0)
554 testmath("Infinity/Math.max", "-0,-0", -Infinity)
555 testmath("Math.max", "Number.POSITIVE_INFINITY, Number.MAX_VALUE", Number.POSITI VE_INFINITY)
556 testmath("Math.max", "Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY", Number .POSITIVE_INFINITY)
557 testmath("Math.max", "Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY", Number .NEGATIVE_INFINITY)
558 testmath("Math.max", "1,.99999999999999", 1)
559 testmath("Math.max", "-1,-.99999999999999", -.99999999999999)
560
561 testmath("Math.min", "void 0, 1", Number.NaN)
562 testmath("Math.min", "void 0, void 0", Number.NaN)
563 testmath("Math.min", "null, 1", 0)
564 testmath("Math.min", "-1, null", -1)
565 testmath("Math.min", "true,false", 0)
566 testmath("Math.min", "\"-99\",\"99\"", -99)
567 testmath("Math.min", "Number.NaN,0", Number.NaN)
568 testmath("Math.min", "Number.NaN,1", Number.NaN)
569 testmath("Math.min", "Number.NaN,-1", Number.NaN)
570 testmath("Math.min", "0,Number.NaN", Number.NaN)
571 testmath("Math.min", "1,Number.NaN", Number.NaN)
572 testmath("Math.min", "-1,Number.NaN", Number.NaN)
573 testmath("Math.min", "Number.NaN,Number.NaN", Number.NaN)
574 testmath("Math.min", "1,1.0000000001", 1)
575 testmath("Math.min", "1.0000000001,1", 1)
576 testmath("Math.min", "0,0", 0)
577 testmath("Math.min", "0,-0", -0)
578 testmath("Math.min", "-0,-0", -0)
579 testmath("Infinity/Math.min", "0,-0", -Infinity)
580 testmath("Infinity/Math.min", "-0,-0", -Infinity)
581
582 testmath("Math.pow", "null,null", 1)
583 testmath("Math.pow", "void 0, void 0", Number.NaN)
584 testmath("Math.pow", "true, false", 1)
585 testmath("Math.pow", "false,true", 0)
586 testmath("Math.pow", "'2','32'", 4294967296)
587 testmath("Math.pow", "1,Number.NaN", Number.NaN)
588 testmath("Math.pow", "0,Number.NaN", Number.NaN)
589 testmath("Math.pow", "Number.NaN,0", 1)
590 testmath("Math.pow", "Number.NaN,-0", 1)
591 testmath("Math.pow", "Number.NaN, 1", Number.NaN)
592 testmath("Math.pow", "Number.NaN, .5", Number.NaN)
593 testmath("Math.pow", "1.00000001, Number.POSITIVE_INFINITY", Number.POSITIVE_INF INITY)
594 testmath("Math.pow", "1.00000001, Number.NEGATIVE_INFINITY", 0)
595 testmath("Math.pow", "-1.00000001,Number.POSITIVE_INFINITY", Number.POSITIVE_INF INITY)
596 testmath("Math.pow", "-1.00000001,Number.NEGATIVE_INFINITY", 0)
597 testmath("Math.pow", "1, Number.POSITIVE_INFINITY", Number.NaN)
598 testmath("Math.pow", "1, Number.NEGATIVE_INFINITY", Number.NaN)
599 testmath("Math.pow", "-1, Number.POSITIVE_INFINITY", Number.NaN)
600 testmath("Math.pow", "-1, Number.NEGATIVE_INFINITY", Number.NaN)
601 testmath("Math.pow", ".0000000009, Number.POSITIVE_INFINITY", 0)
602 testmath("Math.pow", "-.0000000009, Number.POSITIVE_INFINITY", 0)
603 testmath("Math.pow", "-.0000000009, Number.NEGATIVE_INFINITY", Number.POSITIVE_I NFINITY)
604 testmath("Math.pow", "Number.POSITIVE_INFINITY,.00000000001", Number.POSITIVE_IN FINITY)
605 testmath("Math.pow", "Number.POSITIVE_INFINITY, 1", Number.POSITIVE_INFINITY)
606 testmath("Math.pow", "Number.POSITIVE_INFINITY, -.00000000001", 0)
607 testmath("Math.pow", "Number.POSITIVE_INFINITY, -1", 0)
608 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 1", Number.NEGATIVE_INFINITY)
609 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 333", Number.NEGATIVE_INFINITY)
610 testmath("Math.pow", "Number.POSITIVE_INFINITY, 2", Number.POSITIVE_INFINITY)
611 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 666", Number.POSITIVE_INFINITY)
612 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 0.5", Number.POSITIVE_INFINITY)
613 testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", Numbe r.POSITIVE_INFINITY)
614 testmath("Math.pow", "Number.NEGATIVE_INFINITY, -1", -0)
615 testmath("Infinity/Math.pow", "Number.NEGATIVE_INFINITY, -1", -Infinity)
616 testmath("Math.pow", "Number.NEGATIVE_INFINITY, -3", -0)
617 testmath("Math.pow", "Number.NEGATIVE_INFINITY, -2", 0)
618 testmath("Math.pow", "Number.NEGATIVE_INFINITY,-0.5", 0)
619 testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", 0)
620 testmath("Math.pow", "0,1", 0)
621 testmath("Math.pow", "0,0", 1)
622 testmath("Math.pow", "1,0", 1)
623 testmath("Math.pow", "-1,0", 1)
624 testmath("Math.pow", "0,0.5", 0)
625 testmath("Math.pow", "0,1000", 0)
626 testmath("Math.pow", "0, Number.POSITIVE_INFINITY", 0)
627 testmath("Math.pow", "0, -1", Number.POSITIVE_INFINITY)
628 testmath("Math.pow", "0, -0.5", Number.POSITIVE_INFINITY)
629 testmath("Math.pow", "0, -1000", Number.POSITIVE_INFINITY)
630 testmath("Math.pow", "0, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
631 testmath("Math.pow", "-0, 1", -0)
632 testmath("Math.pow", "-0,3", -0)
633 testmath("Infinity/Math.pow", "-0, 1", -Infinity)
634 testmath("Infinity/Math.pow", "-0,3", -Infinity)
635 testmath("Math.pow", "-0,2", 0)
636 testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0)
637 testmath("Math.pow", "-0, -1", Number.NEGATIVE_INFINITY)
638 testmath("Math.pow", "-0, -10001", Number.NEGATIVE_INFINITY)
639 testmath("Math.pow", "-0, -2", Number.POSITIVE_INFINITY)
640 testmath("Math.pow", "-0, 0.5", 0)
641 testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0)
642 testmath("Math.pow", "-1, 0.5", Number.NaN)
643 testmath("Math.pow", "-1, Number.NaN", Number.NaN)
644 testmath("Math.pow", "-1, -0.5", Number.NaN)
645
646 testmath("Math.round", "0", 0)
647 testmath("Math.round", "void 0", Number.NaN)
648 testmath("Math.round", "true", 1)
649 testmath("Math.round", "false", 0)
650 testmath("Math.round", "'.99999'", 1)
651 testmath("Math.round", "'12345e-2'", 123)
652 testmath("Math.round", "Number.NaN", Number.NaN)
653 testmath("Math.round", "0", 0)
654 testmath("Math.round", "-0", -0)
655 testmath("Infinity/Math.round", "-0", -Infinity)
656 testmath("Math.round", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
657 testmath("Math.round", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
658 testmath("Math.round", "0.49", 0)
659 testmath("Math.round", "0.5", 1)
660 testmath("Math.round", "0.51", 1)
661 testmath("Math.round", "-0.49", -0)
662 testmath("Math.round", "-0.5", -0)
663 testmath("Infinity/Math.round", "-0.49", -Infinity)
664 testmath("Infinity/Math.round", "-0.5", -Infinity)
665 testmath("Math.round", "-0.51", -1)
666 testmath("Math.round", "3.5", 4)
667 testmath("Math.round", "-3", -3)
668
669 testmath("Math.sin", "null", 0)
670 testmath("Math.sin", "void 0", Number.NaN)
671 testmath("Math.sin", "false", 0)
672 testmath("Math.sin", "'2.356194490192'", 0.7071067811865)
673 testmath("Math.sin", "Number.NaN", Number.NaN)
674 testmath("Math.sin", "0", 0)
675 testmath("Math.sin", "-0", -0)
676 testmath("Math.sin", "Number.POSITIVE_INFINITY", Number.NaN)
677 testmath("Math.sin", "Number.NEGATIVE_INFINITY", Number.NaN)
678 testmath("Math.sin", "0.7853981633974", 0.7071067811865)
679 testmath("Math.sin", "1.570796326795", 1)
680 testmath("Math.sin", "2.356194490192", 0.7071067811865)
681 testmath("Math.sin", "3.14159265359", 0)
682
683 testmath("Math.sqrt", "void 0", Number.NaN)
684 testmath("Math.sqrt", "null", 0)
685 testmath("Math.sqrt", "1", 1)
686 testmath("Math.sqrt", "false", 0)
687 testmath("Math.sqrt", "'225'", 15)
688 testmath("Math.sqrt", "Number.NaN", Number.NaN)
689 testmath("Math.sqrt", "Number.NEGATIVE_INFINITY", Number.NaN)
690 testmath("Math.sqrt", "-1", Number.NaN)
691 testmath("Math.sqrt", "-0.5", Number.NaN)
692 testmath("Math.sqrt", "0", 0)
693 testmath("Math.sqrt", "-0", -0)
694 testmath("Infinity/Math.sqrt", "-0", -Infinity)
695 testmath("Math.sqrt", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
696 testmath("Math.sqrt", "1", 1)
697 testmath("Math.sqrt", "2", Math.SQRT2)
698 testmath("Math.sqrt", "0.5", Math.SQRT1_2)
699 testmath("Math.sqrt", "4", 2)
700 testmath("Math.sqrt", "9", 3)
701 testmath("Math.sqrt", "16", 4)
702 testmath("Math.sqrt", "25", 5)
703 testmath("Math.sqrt", "36", 6)
704 testmath("Math.sqrt", "49", 7)
705 testmath("Math.sqrt", "64", 8)
706 testmath("Math.sqrt", "256", 16)
707 testmath("Math.sqrt", "10000", 100)
708 testmath("Math.sqrt", "65536", 256)
709 testmath("Math.sqrt", "0.09", 0.3)
710 testmath("Math.sqrt", "0.01", 0.1)
711 testmath("Math.sqrt", "0.00000001", 0.0001)
712
713 testmath("Math.tan", "void 0", Number.NaN)
714 testmath("Math.tan", "null", 0)
715 testmath("Math.tan", "false", 0)
716 testmath("Math.tan", "Number.NaN", Number.NaN)
717 testmath("Math.tan", "0", 0)
718 testmath("Math.tan", "-0", -0)
719 testmath("Math.tan", "Number.POSITIVE_INFINITY", Number.NaN)
720 testmath("Math.tan", "Number.NEGATIVE_INFINITY", Number.NaN)
721 testmath("Math.tan", "Math.PI/4", 1)
722 testmath("Math.tan", "3*Math.PI/4", -1)
723 testmath("Math.tan", "Math.PI", -0)
724 testmath("Math.tan", "5*Math.PI/4", 1)
725 testmath("Math.tan", "7*Math.PI/4", -1)
726 testmath("Infinity/Math.tan", "-0", -Infinity)
727
728 jit(false);
729
730 /* Keep these at the end so that we can see the summary after the trace-debug sp ew. */
731 if (0) {
732 print("\npassed:", passes.length && passes.join(","));
733 print("\nFAILED:", fails.length && fails.join(","));
734 }
OLDNEW
« no previous file with comments | « mozilla-tests/js1_8_1/regress/shell.js ('k') | mozilla-tests/js1_8_1/trace/regress-451673.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698