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

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

Issue 2987793002: Migrate test block 7 to Dart 2.0. (Closed)
Patch Set: Final review comment, dropping static multitest Created 3 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'package:expect/expect.dart';
6
7 main() {
8 Expect.equals(0, 0.0.truncate());
9 Expect.equals(0, double.MIN_POSITIVE.truncate());
10 Expect.equals(0, (2.0 * double.MIN_POSITIVE).truncate());
11 Expect.equals(0, (1.18e-38).truncate());
12 Expect.equals(0, (1.18e-38 * 2).truncate());
13 Expect.equals(0, 0.49999999999999994.truncate());
14 Expect.equals(0, 0.5.truncate());
15 Expect.equals(0, 0.9999999999999999.truncate());
16 Expect.equals(1, 1.0.truncate());
17 Expect.equals(1, 1.000000000000001.truncate());
18 // The following numbers are on the border of 52 bits.
19 // For example: 4503599627370499 + 0.5 => 4503599627370500.
20 Expect.equals(4503599627370496, 4503599627370496.0.truncate());
21 Expect.equals(4503599627370497, 4503599627370497.0.truncate());
22 Expect.equals(4503599627370498, 4503599627370498.0.truncate());
23 Expect.equals(4503599627370499, 4503599627370499.0.truncate());
24
25 Expect.equals(9007199254740991, 9007199254740991.0.truncate());
26 Expect.equals(9007199254740992, 9007199254740992.0.truncate());
27 Expect.equals(
28 17976931348623157081452742373170435679807056752584499659891747680315726078 00285387605895586327668781715404589535143824642343213268894641827684675467035375 16986049910576551282076245490090389328944075868508455133942304583236903222948165 808559332123348274797826204144723168738177180919299881250404026184124858368,
29 double.MAX_FINITE.truncate());
30
31 Expect.equals(0, (-double.MIN_POSITIVE).truncate());
32 Expect.equals(0, (2.0 * -double.MIN_POSITIVE).truncate());
33 Expect.equals(0, (-1.18e-38).truncate());
34 Expect.equals(0, (-1.18e-38 * 2).truncate());
35 Expect.equals(0, (-0.49999999999999994).truncate());
36 Expect.equals(0, (-0.5).truncate());
37 Expect.equals(0, (-0.9999999999999999).truncate());
38 Expect.equals(-1, (-1.0).truncate());
39 Expect.equals(-1, (-1.000000000000001).truncate());
40 Expect.equals(-4503599627370496, (-4503599627370496.0).truncate());
41 Expect.equals(-4503599627370497, (-4503599627370497.0).truncate());
42 Expect.equals(-4503599627370498, (-4503599627370498.0).truncate());
43 Expect.equals(-4503599627370499, (-4503599627370499.0).truncate());
44 Expect.equals(-9007199254740991, (-9007199254740991.0).truncate());
45 Expect.equals(-9007199254740992, (-9007199254740992.0).truncate());
46 Expect.equals(
47 -1797693134862315708145274237317043567980705675258449965989174768031572607 80028538760589558632766878171540458953514382464234321326889464182768467546703537 51698604991057655128207624549009038932894407586850845513394230458323690322294816 5808559332123348274797826204144723168738177180919299881250404026184124858368,
48 (-double.MAX_FINITE).truncate());
49
50 Expect.isTrue(0.0.truncate() is int);
51 Expect.isTrue(double.MIN_POSITIVE.truncate() is int);
52 Expect.isTrue((2.0 * double.MIN_POSITIVE).truncate() is int);
53 Expect.isTrue((1.18e-38).truncate() is int);
54 Expect.isTrue((1.18e-38 * 2).truncate() is int);
55 Expect.isTrue(0.49999999999999994.truncate() is int);
56 Expect.isTrue(0.5.truncate() is int);
57 Expect.isTrue(0.9999999999999999.truncate() is int);
58 Expect.isTrue(1.0.truncate() is int);
59 Expect.isTrue(1.000000000000001.truncate() is int);
60 Expect.isTrue(4503599627370496.0.truncate() is int);
61 Expect.isTrue(4503599627370497.0.truncate() is int);
62 Expect.isTrue(4503599627370498.0.truncate() is int);
63 Expect.isTrue(4503599627370499.0.truncate() is int);
64 Expect.isTrue(9007199254740991.0.truncate() is int);
65 Expect.isTrue(9007199254740992.0.truncate() is int);
66 Expect.isTrue(double.MAX_FINITE.truncate() is int);
67
68 Expect.isTrue((-double.MIN_POSITIVE).truncateToDouble().isNegative);
69 Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncateToDouble().isNegative);
70 Expect.isTrue((-1.18e-38).truncateToDouble().isNegative);
71 Expect.isTrue((-1.18e-38 * 2).truncateToDouble().isNegative);
72 Expect.isTrue((-0.49999999999999994).truncateToDouble().isNegative);
73 Expect.isTrue((-0.5).truncateToDouble().isNegative);
74 Expect.isTrue((-0.9999999999999999).truncateToDouble().isNegative);
75
76 Expect.isTrue((-double.MIN_POSITIVE).truncate() is int);
77 Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncate() is int);
78 Expect.isTrue((-1.18e-38).truncate() is int);
79 Expect.isTrue((-1.18e-38 * 2).truncate() is int);
80 Expect.isTrue((-0.49999999999999994).truncate() is int);
81 Expect.isTrue((-0.5).truncate() is int);
82 Expect.isTrue((-0.9999999999999999).truncate() is int);
83 Expect.isTrue((-1.0).truncate() is int);
84 Expect.isTrue((-1.000000000000001).truncate() is int);
85 Expect.isTrue((-4503599627370496.0).truncate() is int);
86 Expect.isTrue((-4503599627370497.0).truncate() is int);
87 Expect.isTrue((-4503599627370498.0).truncate() is int);
88 Expect.isTrue((-4503599627370499.0).truncate() is int);
89 Expect.isTrue((-9007199254740991.0).truncate() is int);
90 Expect.isTrue((-9007199254740992.0).truncate() is int);
91 Expect.isTrue((-double.MAX_FINITE).truncate() is int);
92 }
OLDNEW
« no previous file with comments | « tests/corelib/double_truncate2_test.dart ('k') | tests/corelib/double_truncate_to_double_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698