| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, 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 // Test program for sync* generator functions and yielding in try blocks. |
| 6 |
| 7 import "package:expect/expect.dart"; |
| 8 |
| 9 f() sync* { |
| 10 try { |
| 11 yield 1; |
| 12 throw "three"; |
| 13 } catch (e) { |
| 14 yield 2; |
| 15 yield e; |
| 16 } finally { |
| 17 yield 4; |
| 18 } |
| 19 } |
| 20 |
| 21 test1() { |
| 22 var s = f().toString(); |
| 23 Expect.equals("(1, 2, three, 4)", s); |
| 24 print(s); |
| 25 } |
| 26 |
| 27 g() sync* { |
| 28 try { |
| 29 yield "a"; |
| 30 throw "pow!"; |
| 31 } finally { |
| 32 yield "b"; |
| 33 } |
| 34 } |
| 35 |
| 36 test2() { |
| 37 var s; |
| 38 try { |
| 39 s = g().toString(); |
| 40 } catch (e) { |
| 41 Expect.equals("pow!", e); |
| 42 Expect.equals("(a, b)", s); |
| 43 print(s); |
| 44 } |
| 45 } |
| 46 |
| 47 main() { |
| 48 test1(); /// test1: ok |
| 49 test2(); /// test2: ok |
| 50 } |
| OLD | NEW |