Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |