Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, 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 // Dart test program for testing try/catch statement without any exceptions | |
| 5 // being thrown. | |
| 6 // VMOptions=--optimization-counter-threshold=100 --no-background-compilation -- enable-inling-annotations | |
|
rmacnak
2016/10/04 21:32:30
inlining
Florian Schneider
2016/10/04 21:36:32
Thanks! Done.
| |
| 7 | |
| 8 // Test local variables updated inside try-catch. | |
| 9 | |
| 10 import "package:expect/expect.dart"; | |
| 11 | |
| 12 const noInline = "NeverInline"; | |
| 13 | |
| 14 @noInline | |
| 15 m1(int b) { | |
| 16 if (b == 1) throw 123; | |
| 17 } | |
| 18 | |
| 19 | |
| 20 @noInline | |
| 21 m2(int b) { | |
| 22 if (b == 2) throw 456; | |
| 23 } | |
| 24 | |
| 25 | |
| 26 @noInline | |
| 27 test(b) { | |
| 28 var state = 0; | |
| 29 try { | |
| 30 state++; | |
| 31 m1(b); | |
| 32 state++; | |
| 33 m2(b); | |
| 34 state++; | |
| 35 } on dynamic catch (e, s) { | |
| 36 if (b == 1 && state != 1) throw "fail1"; | |
| 37 if (b == 2 && state != 2) throw "fail2"; | |
| 38 if (b == 3 && state != 3) throw "fail3"; | |
| 39 return e; | |
| 40 } | |
| 41 return "no throw"; | |
| 42 } | |
| 43 | |
| 44 main() { | |
| 45 for (var i=0; i<300; i++) { | |
| 46 Expect.equals("no throw", test(0)); | |
| 47 } | |
| 48 Expect.equals("no throw", test(0)); | |
| 49 Expect.equals(123, test(1)); | |
| 50 Expect.equals(456, test(2)); | |
| 51 } | |
| OLD | NEW |