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

Unified Diff: test/codegen/corelib/double_compare_test.dart

Issue 1945153002: Add corelib tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: error_test and range_error_test now pass Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/codegen/corelib/double_ceil_to_double_test.dart ('k') | test/codegen/corelib/double_floor2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/corelib/double_compare_test.dart
diff --git a/test/codegen/corelib/double_compare_test.dart b/test/codegen/corelib/double_compare_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..287baacb260c3b312c5eaf530448bd2668bcd099
--- /dev/null
+++ b/test/codegen/corelib/double_compare_test.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Dart test program for testing 'compare' on doubles.
+
+void main() {
+ Expect.equals(0, (0.0).compareTo(0.0));
+ Expect.equals(0, (1.0).compareTo(1.0));
+ Expect.equals(0, (-2.0).compareTo(-2.0));
+ Expect.equals(0, (1e-50).compareTo(1e-50));
+ Expect.equals(0, (-2e50).compareTo(-2e50));
+ Expect.equals(0, double.NAN.compareTo(double.NAN));
+ Expect.equals(0, double.INFINITY.compareTo(double.INFINITY));
+ Expect.equals(0,
+ double.NEGATIVE_INFINITY.compareTo(double.NEGATIVE_INFINITY));
+ Expect.equals(0, (-0.0).compareTo(-0.0));
+ Expect.isTrue((0.0).compareTo(1.0) < 0);
+ Expect.isTrue((1.0).compareTo(0.0) > 0);
+ Expect.isTrue((0.0).compareTo(-1.0) > 0);
+ Expect.isTrue((-1.0).compareTo(0.0) < 0);
+ Expect.isTrue((0.0).compareTo(1234e11) < 0);
+ Expect.isTrue((123e-112).compareTo(0.0) > 0);
+ Expect.isTrue((0.0).compareTo(-123.0e12) > 0);
+ Expect.isTrue((-1.0e8).compareTo(0.0) < 0);
+
+ double maxDouble = 1.7976931348623157e308;
+ Expect.equals(0, maxDouble.compareTo(maxDouble));
+ Expect.isTrue(maxDouble.compareTo(double.INFINITY) < 0);
+ Expect.isTrue(double.INFINITY.compareTo(maxDouble) > 0);
+
+ double negMaxDouble = -maxDouble;
+ Expect.equals(0, negMaxDouble.compareTo(negMaxDouble));
+ Expect.isTrue(double.NEGATIVE_INFINITY.compareTo(negMaxDouble) < 0);
+ Expect.isTrue(negMaxDouble.compareTo(double.NEGATIVE_INFINITY) > 0);
+
+ Expect.isTrue((-0.0).compareTo(0.0) < 0);
+ Expect.isTrue((0.0).compareTo(-0.0) > 0);
+ Expect.isTrue(double.NAN.compareTo(double.INFINITY) > 0);
+ Expect.isTrue(double.NAN.compareTo(double.NEGATIVE_INFINITY) > 0);
+ Expect.isTrue(double.INFINITY.compareTo(double.NAN) < 0);
+ Expect.isTrue(double.NEGATIVE_INFINITY.compareTo(double.NAN) < 0);
+ Expect.isTrue(maxDouble.compareTo(double.NAN) < 0);
+ Expect.isTrue(negMaxDouble.compareTo(double.NAN) < 0);
+ Expect.isTrue(double.NAN.compareTo(maxDouble) > 0);
+ Expect.isTrue(double.NAN.compareTo(negMaxDouble) > 0);
+}
« no previous file with comments | « test/codegen/corelib/double_ceil_to_double_test.dart ('k') | test/codegen/corelib/double_floor2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698