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

Unified Diff: tests/standalone/53bit_overflow_test.dart

Issue 15743017: Adds a flag to the standalone vm to throw an exception on 53-bit integer overflow. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « sdk/lib/core/errors.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/53bit_overflow_test.dart
===================================================================
--- tests/standalone/53bit_overflow_test.dart (revision 0)
+++ tests/standalone/53bit_overflow_test.dart (revision 0)
@@ -0,0 +1,47 @@
+// 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.
+
+// VMOptions=--throw_on_javascript_int_overflow
+
+
+import "package:expect/expect.dart";
+import 'dart:typed_data';
+
+
+int double_to_int_throws() {
+ double d = 1.9e16;
+ return d.toInt();
+}
+
+
+int integer_add_throws() {
+ return (1 << 52) + (1 << 52);
+}
+
+
+int i64list_throws() {
+ var i64l = new Int64List(16);
+ i64l[0] = (1 << 54);
+ return i64l[0];
+}
+
+
+int double_to_int() {
+ double d = 1.9e14;
+ return d.toInt();
+}
+
+
+int integer_add() {
+ return (1 << 50) + (1 << 50);
+}
+
+
+main() {
+ Expect.throws(double_to_int_throws, (e) => e is FiftyThreeBitOverflowError);
+ Expect.throws(integer_add_throws, (e) => e is FiftyThreeBitOverflowError);
+ Expect.throws(i64list_throws, (e) => e is FiftyThreeBitOverflowError);
+ Expect.equals(190000000000000, double_to_int());
+ Expect.equals(1 << 51, integer_add());
+}
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698