Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: tests/lib/async/zone_fork_test.dart

Issue 2893893002: Use generic functions in zones. (Closed)
Patch Set: Fix more tests. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import 'package:async_helper/async_helper.dart'; 6 import 'package:async_helper/async_helper.dart';
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 main() { 9 main() {
10 Completer done = new Completer(); 10 Completer done = new Completer();
11 List events = []; 11 List events = [];
12 12
13 Expect.identical(Zone.ROOT, Zone.current); 13 Expect.identical(Zone.ROOT, Zone.current);
14 Zone forked; 14 Zone forked;
15 forked = Zone.current.fork(specification: new ZoneSpecification(fork: 15 forked = Zone.current.fork(specification: new ZoneSpecification(fork:
16 (Zone self, ZoneDelegate parent, Zone origin, 16 (Zone self, ZoneDelegate parent, Zone origin,
17 ZoneSpecification zoneSpecification, Map mapValues) { 17 ZoneSpecification zoneSpecification, Map mapValues) {
18 // The zone is still the same as when origin.run was invoked, which 18 // The zone is still the same as when origin.run was invoked, which
19 // is the root zone. (The origin zone hasn't been set yet). 19 // is the root zone. (The origin zone hasn't been set yet).
20 Expect.identical(Zone.ROOT, Zone.current); 20 Expect.identical(Zone.ROOT, Zone.current);
21 events.add("forked.fork"); 21 events.add("forked.fork");
22 Function descriptionRun = zoneSpecification.run; 22 Function descriptionRun = zoneSpecification.run;
23 ZoneSpecification modified = new ZoneSpecification.from(zoneSpecification, 23 ZoneSpecification modified = new ZoneSpecification.from(zoneSpecification,
24 run: (self, parent, origin, f) { 24 run: <R>(self, parent, origin, R f()) {
25 events.add("wrapped run"); 25 events.add("wrapped run");
26 return descriptionRun(self, parent, origin, () { 26 return descriptionRun<R>(self, parent, origin, () {
27 events.add("wrapped f"); 27 events.add("wrapped f");
28 return f(); 28 return f();
29 }); 29 });
30 }); 30 });
31 return parent.fork(origin, modified, mapValues); 31 return parent.fork(origin, modified, mapValues);
32 })); 32 }));
33 33
34 events.add("start"); 34 events.add("start");
35 Zone forkedChild = forked.fork(specification: new ZoneSpecification( 35 Zone forkedChild = forked.fork(specification: new ZoneSpecification(
36 run: (Zone self, ZoneDelegate parent, Zone origin, f()) { 36 run: <R>(Zone self, ZoneDelegate parent, Zone origin, R f()) {
37 events.add("executing child run"); 37 events.add("executing child run");
38 return parent.run(origin, f); 38 return parent.run(origin, f);
39 })); 39 }));
40 40
41 events.add("after child fork"); 41 events.add("after child fork");
42 Expect.identical(Zone.ROOT, Zone.current); 42 Expect.identical(Zone.ROOT, Zone.current);
43 43
44 forkedChild.run(() { 44 forkedChild.run(() {
45 events.add("child run"); 45 events.add("child run");
46 }); 46 });
47 47
48 events.add("after child run"); 48 events.add("after child run");
49 49
50 Expect.listEquals([ 50 Expect.listEquals([
51 "start", 51 "start",
52 "forked.fork", 52 "forked.fork",
53 "after child fork", 53 "after child fork",
54 "wrapped run", 54 "wrapped run",
55 "executing child run", 55 "executing child run",
56 "wrapped f", 56 "wrapped f",
57 "child run", 57 "child run",
58 "after child run" 58 "after child run"
59 ], events); 59 ], events);
60 } 60 }
OLDNEW
« no previous file with comments | « tests/lib/async/zone_error_callback_test.dart ('k') | tests/lib/async/zone_register_callback_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698