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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | no next file » | 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) 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 // VMOptions=--throw_on_javascript_int_overflow
6
7
8 import "package:expect/expect.dart";
9 import 'dart:typed_data';
10
11
12 int double_to_int_throws() {
13 double d = 1.9e16;
14 return d.toInt();
15 }
16
17
18 int integer_add_throws() {
19 return (1 << 52) + (1 << 52);
20 }
21
22
23 int i64list_throws() {
24 var i64l = new Int64List(16);
25 i64l[0] = (1 << 54);
26 return i64l[0];
27 }
28
29
30 int double_to_int() {
31 double d = 1.9e14;
32 return d.toInt();
33 }
34
35
36 int integer_add() {
37 return (1 << 50) + (1 << 50);
38 }
39
40
41 main() {
42 Expect.throws(double_to_int_throws, (e) => e is FiftyThreeBitOverflowError);
43 Expect.throws(integer_add_throws, (e) => e is FiftyThreeBitOverflowError);
44 Expect.throws(i64list_throws, (e) => e is FiftyThreeBitOverflowError);
45 Expect.equals(190000000000000 ,double_to_int());
srdjan 2013/06/05 15:32:00 Fix comma formatting.
46 Expect.equals(1 << 51, integer_add());
47 }
OLDNEW
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698