OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 library stream_listen_zeno_test; | 5 library stream_listen_zeno_test; |
6 | 6 |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 nextStep(); | 57 nextStep(); |
58 }, onDone: () { | 58 }, onDone: () { |
59 Expect.identical(zone, Zone.current, name); | 59 Expect.identical(zone, Zone.current, name); |
60 if (overrideDone) throw "RUNNING WRONG ONDONE"; | 60 if (overrideDone) throw "RUNNING WRONG ONDONE"; |
61 callbackBits |= 4; | 61 callbackBits |= 4; |
62 nextStep(); | 62 nextStep(); |
63 }); | 63 }); |
64 registerExpect += 3; | 64 registerExpect += 3; |
65 Expect.equals(registerExpect, registerCount, name); | 65 Expect.equals(registerExpect, registerCount, name); |
66 }, | 66 }, |
67 zoneSpecification: | 67 zoneSpecification: new ZoneSpecification( |
68 new ZoneSpecification(registerCallback: (self, p, z, callback()) { | 68 registerCallback: <R>(self, p, z, R callback()) { |
69 Expect.identical(zone, self, name); | 69 Expect.identical(zone, self, name); |
70 registerCount++; | 70 registerCount++; |
71 return () { | 71 return () { |
72 Expect.identical(zone, Zone.current, name); | 72 Expect.identical(zone, Zone.current, name); |
73 callback(); | 73 return callback(); |
74 }; | 74 }; |
75 }, registerUnaryCallback: (self, p, z, callback(a)) { | 75 }, registerUnaryCallback: <R, T>(self, p, z, R callback(T a)) { |
76 Expect.identical(zone, self, name); | 76 Expect.identical(zone, self, name); |
77 registerCount++; | 77 registerCount++; |
78 return (a) { | 78 return (a) { |
79 Expect.identical(zone, Zone.current, name); | 79 Expect.identical(zone, Zone.current, name); |
80 callback(a); | 80 return callback(a); |
81 }; | 81 }; |
82 }, registerBinaryCallback: (self, package, z, callback(a, b)) { | 82 }, registerBinaryCallback: |
| 83 <R, T1, T2>(self, package, z, R callback(T1 a, T2 b)) { |
83 Expect.identical(zone, self, name); | 84 Expect.identical(zone, self, name); |
84 registerCount++; | 85 registerCount++; |
85 return (a, b) { | 86 return (a, b) { |
86 Expect.identical(zone, Zone.current, name); | 87 Expect.identical(zone, Zone.current, name); |
87 callback(a, b); | 88 return callback(a, b); |
88 }; | 89 }; |
89 })); | 90 })); |
90 | 91 |
91 int expectedBits = 0; | 92 int expectedBits = 0; |
92 step = () { | 93 step = () { |
93 var stepName = "$name-$stepCount"; | 94 var stepName = "$name-$stepCount"; |
94 Expect.identical(Zone.ROOT, Zone.current, stepName); | 95 Expect.identical(Zone.ROOT, Zone.current, stepName); |
95 Expect.equals(expectedBits, callbackBits, stepName); | 96 Expect.equals(expectedBits, callbackBits, stepName); |
96 switch (stepCount++) { | 97 switch (stepCount++) { |
97 case 0: | 98 case 0: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 142 } |
142 Expect.equals(registerExpect, registerCount, stepName); | 143 Expect.equals(registerExpect, registerCount, stepName); |
143 controller.close(); | 144 controller.close(); |
144 break; | 145 break; |
145 case 5: | 146 case 5: |
146 asyncEnd(); | 147 asyncEnd(); |
147 } | 148 } |
148 }; | 149 }; |
149 step(); | 150 step(); |
150 } | 151 } |
OLD | NEW |