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

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

Issue 2987203002: Migrated test block 17 to Dart 2.0. (Closed)
Patch Set: Removed tests that are no longer useful for Dart 2.0 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
« no previous file with comments | « tests/corelib/maps_test.dart ('k') | tests/corelib/null_nosuchmethod_test.dart » ('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 // Copyright (c) 2011, 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 // Dart test program for testing NaN and Infinity.
8
9 void main() {
10 // Sanity tests.
11 Expect.isFalse(1.5.isNaN);
12 Expect.isFalse(1.5.isInfinite);
13 Expect.isTrue(1.5.isFinite);
14 Expect.isFalse(1.5.isNegative);
15 Expect.isTrue((-1.5).isNegative);
16 Expect.isFalse(0.0.isNegative);
17 Expect.isTrue((-0.0).isNegative);
18 Expect.isTrue((-0.0).isFinite);
19
20 Expect.isFalse(1.isNaN);
21 Expect.isFalse(1.isInfinite);
22 Expect.isTrue(1.isFinite);
23 Expect.isFalse(1.isNegative);
24 Expect.isTrue((-1).isNegative);
25
26 // Test that predicates give the correct result.
27 Expect.isTrue(double.NAN.isNaN);
28 Expect.isFalse(double.NAN.isInfinite);
29 Expect.isFalse(double.NAN.isFinite);
30 Expect.isFalse(double.NAN.isNegative);
31 Expect.isFalse((-double.NAN).isNegative);
32
33 Expect.isFalse(double.INFINITY.isNaN);
34 Expect.isTrue(double.INFINITY.isInfinite);
35 Expect.isFalse(double.INFINITY.isFinite);
36 Expect.isFalse(double.INFINITY.isNegative);
37 Expect.isTrue((-double.INFINITY).isNegative);
38
39 Expect.isFalse(double.NEGATIVE_INFINITY.isNaN);
40 Expect.isTrue(double.NEGATIVE_INFINITY.isInfinite);
41 Expect.isFalse(double.NEGATIVE_INFINITY.isFinite);
42 Expect.isTrue(double.NEGATIVE_INFINITY.isNegative);
43 Expect.isFalse((-double.NEGATIVE_INFINITY).isNegative);
44
45 // Test toString.
46 Expect.equals("NaN", double.NAN.toString());
47 Expect.equals("Infinity", double.INFINITY.toString());
48 Expect.equals("-Infinity", double.NEGATIVE_INFINITY.toString());
49
50 // Test identities.
51 Expect.isTrue(identical(double.NAN, double.NAN)); // //# 01: ok
52 Expect.isTrue(identical(double.INFINITY, double.INFINITY));
53 Expect.isTrue(identical(double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY));
54 Expect.isFalse(identical(double.NAN, double.INFINITY));
55 Expect.isFalse(identical(double.NAN, double.NEGATIVE_INFINITY));
56 Expect.isFalse(identical(double.INFINITY, double.NEGATIVE_INFINITY));
57 Expect.isFalse(identical(double.NAN, -double.NAN));
58 Expect.isTrue(identical(double.INFINITY, -double.NEGATIVE_INFINITY));
59 Expect.isTrue(identical(double.NEGATIVE_INFINITY, -double.INFINITY));
60
61 // Test equalities
62 Expect.isTrue(double.INFINITY == double.INFINITY);
63 Expect.isTrue(double.NEGATIVE_INFINITY == double.NEGATIVE_INFINITY);
64 Expect.isFalse(double.INFINITY == double.NEGATIVE_INFINITY);
65 Expect.isFalse(double.NEGATIVE_INFINITY == double.INFINITY);
66 Expect.isFalse(double.NAN == double.NAN);
67 Expect.isFalse(double.NAN == double.INFINITY);
68 Expect.isFalse(double.NAN == double.NEGATIVE_INFINITY);
69 Expect.isFalse(double.INFINITY == double.NAN);
70 Expect.isFalse(double.NEGATIVE_INFINITY == double.NAN);
71
72 // Test relational order.
73 Expect.isFalse(double.NAN < double.NAN);
74 Expect.isFalse(double.NAN < double.INFINITY);
75 Expect.isFalse(double.NAN < double.NEGATIVE_INFINITY);
76 Expect.isFalse(double.NAN > double.NAN);
77 Expect.isFalse(double.NAN > double.INFINITY);
78 Expect.isFalse(double.NAN > double.NEGATIVE_INFINITY);
79 Expect.isFalse(double.INFINITY < double.NAN);
80 Expect.isFalse(double.NEGATIVE_INFINITY < double.NAN);
81 Expect.isFalse(double.INFINITY > double.NAN);
82 Expect.isFalse(double.NEGATIVE_INFINITY > double.NAN);
83 Expect.isTrue(double.INFINITY > double.NEGATIVE_INFINITY);
84 Expect.isFalse(double.INFINITY < double.NEGATIVE_INFINITY);
85
86 // NaN is contagious.
87 Expect.isTrue((3.0 * double.NAN).isNaN);
88 Expect.isTrue((3.0 + double.NAN).isNaN);
89 Expect.isTrue((-double.NAN).isNaN);
90 }
OLDNEW
« no previous file with comments | « tests/corelib/maps_test.dart ('k') | tests/corelib/null_nosuchmethod_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698