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

Unified Diff: dart/tests/language/round_test.dart

Issue 23595002: Triage Safari bug 7414. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/language/round_test.dart
diff --git a/dart/tests/language/round_test.dart b/dart/tests/language/round_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..09bc14aae576efd03e0f74c09fae3d0a7b69ca1b
--- /dev/null
+++ b/dart/tests/language/round_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2013, 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.
+
+/// Test of a rounding of a common rounding bug.
+///
+/// This bug is common in JavaScript implementations because the ECMA-262
+/// specification of JavaScript incorrectly claims:
+///
+/// The value of [:Math.round(x):] is the same as the value of
+/// [:Math.floor(x+0.5):], except when x is 0 or is less than 0 but greater
+/// than or equal to -0.5; for these cases [:Math.round(x):] returns 0, but
+/// [:Math.floor(x+0.5):] returns +0.
+///
+/// However, 0.49999999999999994 + 0.5 is 1 and 9007199254740991 + 0.5 is
+/// 9007199254740992, so you cannot implement Math.round in terms of
+/// Math.floor.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0, (0.49999999999999994).round());
+ Expect.equals(0, (-0.49999999999999994).round());
+
+ Expect.equals(9007199254740991, (9007199254740991.0).round());
+ Expect.equals(-9007199254740991, (-9007199254740991.0).round());
+}
« no previous file with comments | « dart/tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698