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

Side by Side Diff: tests/corelib/compare_to2_test.dart

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 11 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
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 5
6 negate(x) => -x; 6 negate(x) => -x;
7 7
8 main() { 8 main() {
9 // Test matrix: 9 // Test matrix:
10 var minNonZero = 5e-324; 10 var minNonZero = 5e-324;
11 var maxDenormal = 2.225073858507201e-308; 11 var maxDenormal = 2.225073858507201e-308;
12 var minNormal = 2.2250738585072014e-308; 12 var minNormal = 2.2250738585072014e-308;
13 var maxFraction = 0.9999999999999999; 13 var maxFraction = 0.9999999999999999;
14 var minAbove1 = 1.0000000000000002; 14 var minAbove1 = 1.0000000000000002;
15 var maxNonInt = 4503599627370495.5; 15 var maxNonInt = 4503599627370495.5;
16 var maxNonIntFloorAsDouble = maxNonInt.floor(); 16 var maxNonIntFloorAsInt = maxNonInt.floor();
17 var maxNonIntFloorAsInt = maxNonIntFloorAsDouble.toInt(); 17 var maxNonIntFloorAsDouble = maxNonIntFloorAsInt.toDouble();
18 var maxExactIntAsDouble = 9007199254740992.0; 18 var maxExactIntAsDouble = 9007199254740992.0;
19 var maxExactIntAsInt = 9007199254740992; 19 var maxExactIntAsInt = 9007199254740992;
20 var two53 = 1 << 53; // Same as maxExactIntAsInt. 20 var two53 = 1 << 53; // Same as maxExactIntAsInt.
21 var two53p1 = two53 + 1; 21 var two53p1 = two53 + 1;
22 var maxFiniteAsDouble = 1.7976931348623157e+308; 22 var maxFiniteAsDouble = 1.7976931348623157e+308;
23 var maxFiniteAsInt = maxFiniteAsDouble.toInt(); 23 var maxFiniteAsInt = maxFiniteAsDouble.truncate();
Lasse Reichstein Nielsen 2013/01/04 10:29:42 Curious. This is actually a use-case for "toInt" :
24 int huge = 1 << 2000; 24 int huge = 1 << 2000;
25 int hugeP1 = huge + 1; 25 int hugeP1 = huge + 1;
26 var inf = double.INFINITY; 26 var inf = double.INFINITY;
27 var nan = double.NAN; 27 var nan = double.NAN;
28 var mnan = negate(nan); 28 var mnan = negate(nan);
29 var matrix = [ 29 var matrix = [
30 -inf, 30 -inf,
31 -hugeP1, 31 -hugeP1,
32 -huge, 32 -huge,
33 [-maxFiniteAsDouble, -maxFiniteAsInt], 33 [-maxFiniteAsDouble, -maxFiniteAsInt],
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 for (int j = 0; j < matrix.length; j++) { 81 for (int j = 0; j < matrix.length; j++) {
82 var left = matrix[i]; 82 var left = matrix[i];
83 var right = matrix[j]; 83 var right = matrix[j];
84 if (left is List) { 84 if (left is List) {
85 check(left, left, 0); 85 check(left, left, 0);
86 } 86 }
87 check(left, right, i == j ? 0 : (i < j ? -1 : 1)); 87 check(left, right, i == j ? 0 : (i < j ? -1 : 1));
88 } 88 }
89 } 89 }
90 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698