| 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 import "package:expect/expect.dart"; | |
| 6 | |
| 7 var x = ""; | |
| 8 | |
| 9 test(String str, [onError(String)]) { | |
| 10 return (() { | |
| 11 try { | |
| 12 throw ""; | |
| 13 } catch(e) { | |
| 14 if (?onError) { | |
| 15 onError(str); | |
| 16 } else { | |
| 17 x = "${str} error"; | |
| 18 } | |
| 19 } | |
| 20 }); | |
| 21 } | |
| 22 | |
| 23 ignoreError(String str) { | |
| 24 x = "${str} error ignored"; | |
| 25 } | |
| 26 | |
| 27 main() { | |
| 28 Expect.equals("", x); | |
| 29 test("test")(); | |
| 30 Expect.equals("test error", x); | |
| 31 test("test", ignoreError)(); | |
| 32 Expect.equals("test error ignored", x); | |
| 33 } | |
| OLD | NEW |