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

Side by Side Diff: tests/lib/math/min_max_test.dart

Issue 19653008: FIx a typo in SIMMIPS min/max and enable min_max_test for SIMMIPS by splitting the main functions i… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test for testing Math.min and Math.max. 4 // Dart test for testing Math.min and Math.max.
5 // VMOptions=--optimization-counter-threshold=10 5 // VMOptions=--optimization-counter-threshold=10
6 6
7 library min_max_test; 7 library min_max_test;
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:math'; 9 import 'dart:math';
10 10
11 testMin() { 11 testMin() {
12 testMin1();
13 testMin2();
14 }
15
16 testMin1() {
12 Expect.equals(0, min(0, 2)); 17 Expect.equals(0, min(0, 2));
13 Expect.equals(0, min(2, 0)); 18 Expect.equals(0, min(2, 0));
14 19
15 Expect.equals(-10, min(-10, -9)); 20 Expect.equals(-10, min(-10, -9));
16 Expect.equals(-10, min(-10, 9)); 21 Expect.equals(-10, min(-10, 9));
17 Expect.equals(-10, min(-10, 0)); 22 Expect.equals(-10, min(-10, 0));
18 Expect.equals(-10, min(-9, -10)); 23 Expect.equals(-10, min(-9, -10));
19 Expect.equals(-10, min(9, -10)); 24 Expect.equals(-10, min(9, -10));
20 Expect.equals(-10, min(0, -10)); 25 Expect.equals(-10, min(0, -10));
21 26
22 Expect.equals(0.5, min(0.5, 2.5)); 27 Expect.equals(0.5, min(0.5, 2.5));
23 Expect.equals(0.5, min(2.5, 0.5)); 28 Expect.equals(0.5, min(2.5, 0.5));
24 29
25 Expect.equals(-10.5, min(-10.5, -9.5)); 30 Expect.equals(-10.5, min(-10.5, -9.5));
26 Expect.equals(-10.5, min(-10.5, 9.5)); 31 Expect.equals(-10.5, min(-10.5, 9.5));
27 Expect.equals(-10.5, min(-10.5, 0.5)); 32 Expect.equals(-10.5, min(-10.5, 0.5));
28 Expect.equals(-10.5, min(-9.5, -10.5)); 33 Expect.equals(-10.5, min(-9.5, -10.5));
29 Expect.equals(-10.5, min(9.5, -10.5)); 34 Expect.equals(-10.5, min(9.5, -10.5));
30 Expect.equals(-10.5, min(0.5, -10.5)); 35 Expect.equals(-10.5, min(0.5, -10.5));
31
32 // Test matrix: 36 // Test matrix:
33 // NaN, -infinity, -499.0, -499, -0.0, 0.0, 0, 499.0, 499, +infinity. 37 // NaN, -infinity, -499.0, -499, -0.0, 0.0, 0, 499.0, 499, +infinity.
34 var inf = double.INFINITY; 38 var inf = double.INFINITY;
35 var nan = double.NAN; 39 var nan = double.NAN;
36 40
37 Expect.isTrue(min(nan, nan).isNaN); 41 Expect.isTrue(min(nan, nan).isNaN);
38 Expect.isTrue(min(nan, -inf).isNaN); 42 Expect.isTrue(min(nan, -inf).isNaN);
39 Expect.isTrue(min(nan, -499.0).isNaN); 43 Expect.isTrue(min(nan, -499.0).isNaN);
40 Expect.isTrue(min(nan, -499).isNaN); 44 Expect.isTrue(min(nan, -499).isNaN);
41 Expect.isTrue(min(nan, -0.0).isNaN); 45 Expect.isTrue(min(nan, -0.0).isNaN);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Expect.isTrue(min(0, nan).isNaN); 169 Expect.isTrue(min(0, nan).isNaN);
166 170
167 Expect.isTrue(min(0, -499.0) is double); 171 Expect.isTrue(min(0, -499.0) is double);
168 Expect.isTrue(min(0, -499) is int); 172 Expect.isTrue(min(0, -499) is int);
169 Expect.isTrue(min(0, -0.0) is double); 173 Expect.isTrue(min(0, -0.0) is double);
170 Expect.isTrue(min(0, 0.0) is int); 174 Expect.isTrue(min(0, 0.0) is int);
171 Expect.isTrue(min(0, 0) is int); 175 Expect.isTrue(min(0, 0) is int);
172 Expect.isTrue(min(0, 499.0) is int); 176 Expect.isTrue(min(0, 499.0) is int);
173 Expect.isTrue(min(0, 499) is int); 177 Expect.isTrue(min(0, 499) is int);
174 Expect.isTrue(min(0, inf) is int); 178 Expect.isTrue(min(0, inf) is int);
179 }
175 180
181 testMin2() {
182 var inf = double.INFINITY;
183 var nan = double.NAN;
176 Expect.isTrue(min(0, -499.0).isNegative); 184 Expect.isTrue(min(0, -499.0).isNegative);
177 Expect.isTrue(min(0, -499).isNegative); 185 Expect.isTrue(min(0, -499).isNegative);
178 Expect.isTrue(min(0, -0.0).isNegative); 186 Expect.isTrue(min(0, -0.0).isNegative);
179 Expect.isFalse(min(0, 0.0).isNegative); 187 Expect.isFalse(min(0, 0.0).isNegative);
180 Expect.isFalse(min(0, 0).isNegative); 188 Expect.isFalse(min(0, 0).isNegative);
181 Expect.isFalse(min(0, 499.0).isNegative); 189 Expect.isFalse(min(0, 499.0).isNegative);
182 Expect.isFalse(min(0, 499).isNegative); 190 Expect.isFalse(min(0, 499).isNegative);
183 Expect.isFalse(min(0, inf).isNegative); 191 Expect.isFalse(min(0, inf).isNegative);
184 192
185 Expect.equals(-inf, min(499.0, -inf)); 193 Expect.equals(-inf, min(499.0, -inf));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 Expect.isTrue(min(inf, -499).isNegative); 272 Expect.isTrue(min(inf, -499).isNegative);
265 Expect.isTrue(min(inf, -0.0).isNegative); 273 Expect.isTrue(min(inf, -0.0).isNegative);
266 Expect.isFalse(min(inf, 0.0).isNegative); 274 Expect.isFalse(min(inf, 0.0).isNegative);
267 Expect.isFalse(min(inf, 0).isNegative); 275 Expect.isFalse(min(inf, 0).isNegative);
268 Expect.isFalse(min(inf, 499).isNegative); 276 Expect.isFalse(min(inf, 499).isNegative);
269 Expect.isFalse(min(inf, 499.0).isNegative); 277 Expect.isFalse(min(inf, 499.0).isNegative);
270 Expect.isFalse(min(inf, inf).isNegative); 278 Expect.isFalse(min(inf, inf).isNegative);
271 } 279 }
272 280
273 testMax() { 281 testMax() {
282 testMax1();
283 testMax2();
284 }
285
286 testMax1() {
274 Expect.equals(2, max(0, 2)); 287 Expect.equals(2, max(0, 2));
275 Expect.equals(2, max(2, 0)); 288 Expect.equals(2, max(2, 0));
276 289
277 Expect.equals(-9, max(-10, -9)); 290 Expect.equals(-9, max(-10, -9));
278 Expect.equals(9, max(-10, 9)); 291 Expect.equals(9, max(-10, 9));
279 Expect.equals(0, max(-10, 0)); 292 Expect.equals(0, max(-10, 0));
280 Expect.equals(-9, max(-9, -10)); 293 Expect.equals(-9, max(-9, -10));
281 Expect.equals(9, max(9, -10)); 294 Expect.equals(9, max(9, -10));
282 Expect.equals(0, max(0, -10)); 295 Expect.equals(0, max(0, -10));
283 296
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 Expect.isTrue(max(-0.0, nan).isNaN); 436 Expect.isTrue(max(-0.0, nan).isNaN);
424 437
425 Expect.isTrue(max(-0.0, 499.0) is double); 438 Expect.isTrue(max(-0.0, 499.0) is double);
426 Expect.isTrue(max(-0.0, 499) is int); 439 Expect.isTrue(max(-0.0, 499) is int);
427 Expect.isTrue(max(-0.0, 0.0) is double); 440 Expect.isTrue(max(-0.0, 0.0) is double);
428 Expect.isTrue(max(-0.0, 0) is int); 441 Expect.isTrue(max(-0.0, 0) is int);
429 Expect.isTrue(max(-0.0, -0.0) is double); 442 Expect.isTrue(max(-0.0, -0.0) is double);
430 Expect.isTrue(max(-0.0, -499) is double); 443 Expect.isTrue(max(-0.0, -499) is double);
431 Expect.isTrue(max(-0.0, -499.0) is double); 444 Expect.isTrue(max(-0.0, -499.0) is double);
432 Expect.isTrue(max(-0.0, -inf) is double); 445 Expect.isTrue(max(-0.0, -inf) is double);
446 }
447
448 testMax2() {
449 var inf = double.INFINITY;
450 var nan = double.NAN;
433 451
434 Expect.isFalse(max(-0.0, 0.0).isNegative); 452 Expect.isFalse(max(-0.0, 0.0).isNegative);
435 Expect.isFalse(max(-0.0, 0).isNegative); 453 Expect.isFalse(max(-0.0, 0).isNegative);
436 Expect.isTrue(max(-0.0, -0.0).isNegative); 454 Expect.isTrue(max(-0.0, -0.0).isNegative);
437 Expect.isTrue(max(-0.0, -499).isNegative); 455 Expect.isTrue(max(-0.0, -499).isNegative);
438 Expect.isTrue(max(-0.0, -499.0).isNegative); 456 Expect.isTrue(max(-0.0, -499.0).isNegative);
439 Expect.isTrue(max(-0.0, -inf).isNegative); 457 Expect.isTrue(max(-0.0, -inf).isNegative);
440 458
441 Expect.equals(inf, max(-499, inf)); 459 Expect.equals(inf, max(-499, inf));
442 Expect.equals(499.0, max(-499, 499.0)); 460 Expect.equals(499.0, max(-499, 499.0));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 Expect.isTrue(max(-inf, -499.0).isNegative); 537 Expect.isTrue(max(-inf, -499.0).isNegative);
520 Expect.isTrue(max(-inf, -inf).isNegative); 538 Expect.isTrue(max(-inf, -inf).isNegative);
521 } 539 }
522 540
523 main() { 541 main() {
524 testMin(); 542 testMin();
525 testMin(); 543 testMin();
526 testMax(); 544 testMax();
527 testMax(); 545 testMax();
528 } 546 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698