OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // VMOptions=--optimization-counter-threshold=10 | 4 // VMOptions=--optimization-counter-threshold=10 |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 // Test unboxed double operations inside try-catch. | 8 // Test unboxed double operations inside try-catch. |
9 foo(bool b) { | 9 foo(bool b) { |
10 if (b) throw 123; | 10 if (b) throw 123; |
11 } | 11 } |
12 | 12 |
13 test_double(double x, bool b) { | 13 test_double(double x, bool b) { |
14 try { | 14 try { |
15 x += 1.0; | 15 x += 1.0; |
16 foo(b); | 16 foo(b); |
17 } catch (e) { | 17 } catch (e) { |
18 var result = x - 1.0; | 18 var result = x - 1.0; |
19 Expect.equals(1.0, result); | 19 Expect.equals(1.0, result); |
20 return result; | 20 return result; |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 main() { | 24 main() { |
25 for (var i = 0; i < 100; i++) test_double(1.0, false); | 25 for (var i = 0; i < 100; i++) test_double(1.0, false); |
26 test_double(1.0, false); | 26 test_double(1.0, false); |
27 Expect.equals(1.0, test_double(1.0, true)); | 27 Expect.equals(1.0, test_double(1.0, true)); |
28 } | 28 } |
29 | |
OLD | NEW |