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