OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 | 4 |
5 // Simple test program for sync* generator functions. | 5 // Simple test program for sync* generator functions. |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import "dart:async"; | 8 import "dart:async"; |
9 | 9 |
10 var sync = "topLevelSync"; | 10 var sync = "topLevelSync"; |
(...skipping 24 matching lines...) Expand all Loading... |
35 return null; // //# 20: compile-time error | 35 return null; // //# 20: compile-time error |
36 } | 36 } |
37 | 37 |
38 test03() sync* => null; // //# 30: compile-time error | 38 test03() sync* => null; // //# 30: compile-time error |
39 | 39 |
40 get test04 sync* => null; // //# 40: compile-time error | 40 get test04 sync* => null; // //# 40: compile-time error |
41 set test04(a) sync* { print(a); } // //# 41: compile-time error | 41 set test04(a) sync* { print(a); } // //# 41: compile-time error |
42 | 42 |
43 class K { | 43 class K { |
44 K() sync* {}; // //# 50: compile-time error | 44 K() sync* {}; // //# 50: compile-time error |
45 get nix sync* {} | 45 get nix sync* { } |
46 get garnix sync* => null; // //# 51: compile-time error | 46 get garnix sync* => null; // //# 51: compile-time error |
47 set etwas(var z) sync* { } // //# 52: compile-time error | 47 set etwas(var z) sync* { } // //# 52: compile-time error |
48 sync() sync* { | 48 sync() sync* { |
49 yield sync; // Yields a tear-off of the sync() method. | 49 yield sync; // Yields a tear-off of the sync() method. |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 main() { | 53 main() { |
54 var x; | 54 var x; |
55 x = test01(); | 55 x = test01(); |
56 Expect.equals("()", x.toString()); | 56 Expect.equals("()", x.toString()); |
57 x = test02(); | 57 x = test02(); |
58 test03(); //# 30: continued | 58 test03(); //# 30: continued |
59 Expect.equals("(12321)", x.toString()); | 59 Expect.equals("(12321)", x.toString()); |
60 x = test04; // //# 40: continued | 60 x = test04; // //# 40: continued |
61 test04 = x; // //# 41: continued | 61 test04 = x; // //# 41: continued |
62 x = new K(); | 62 x = new K(); |
63 print(x.garnix); //# 51: continued | 63 print(x.garnix); //# 51: continued |
64 x.etwas = null; //# 52: continued | 64 x.etwas = null; //# 52: continued |
65 print(x.sync().toList()); | 65 print(x.sync().toList()); |
66 Expect.equals(1, x.sync().length); | 66 Expect.equals(1, x.sync().length); |
67 // Expect.isTrue(x.sync().single is Function); | 67 // Expect.isTrue(x.sync().single is Function); |
68 } | 68 } |
OLD | NEW |