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

Side by Side Diff: pkg/scheduled_test/lib/src/scheduled_server/handler.dart

Issue 93143002: Make pkg/stack_trace use stack chains. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 library scheduled_server.handler; 5 library scheduled_server.handler;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../../scheduled_server.dart'; 9 import '../../scheduled_server.dart';
10 import '../../scheduled_test.dart'; 10 import '../../scheduled_test.dart';
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return _waitForTask().then((_) { 46 return _waitForTask().then((_) {
47 if (!ready) { 47 if (!ready) {
48 fail("'${server.description}' received " 48 fail("'${server.description}' received "
49 "$method $path earlier than expected."); 49 "$method $path earlier than expected.");
50 } 50 }
51 51
52 // Use a nested call to [schedule] to help the user tell the difference 52 // Use a nested call to [schedule] to help the user tell the difference
53 // between a test failing while waiting for a handler and a test failing 53 // between a test failing while waiting for a handler and a test failing
54 // while executing a handler. 54 // while executing a handler.
55 chainToCompleter(schedule(() { 55 chainToCompleter(schedule(() {
56 return new Future.sync(() { 56 return syncFuture(() {
57 if (request.method != method || request.uri.path != path) { 57 if (request.method != method || request.uri.path != path) {
58 fail("'${server.description}' expected $method $path, " 58 fail("'${server.description}' expected $method $path, "
59 "but got ${request.method} ${request.uri.path}."); 59 "but got ${request.method} ${request.uri.path}.");
60 } 60 }
61 61
62 return fn(request); 62 return fn(request);
63 }); 63 });
64 }, "'${server.description}' handling ${request.method} ${request.uri}"), 64 }, "'${server.description}' handling ${request.method} ${request.uri}"),
65 _resultCompleter); 65 _resultCompleter);
66 }); 66 });
67 }; 67 };
68 } 68 }
69 69
70 /// If the current task is [_taskBefore], waits for it to finish before 70 /// If the current task is [_taskBefore], waits for it to finish before
71 /// completing. Otherwise, completes immediately. 71 /// completing. Otherwise, completes immediately.
72 Future _waitForTask() { 72 Future _waitForTask() {
73 return pumpEventQueue().then((_) { 73 return pumpEventQueue().then((_) {
74 if (currentSchedule.currentTask != _taskBefore) return; 74 if (currentSchedule.currentTask != _taskBefore) return null;
75 // If we're one task before the handler was scheduled, wait for that 75 // If we're one task before the handler was scheduled, wait for that
76 // task to complete and pump the event queue so that [ready] will be 76 // task to complete and pump the event queue so that [ready] will be
77 // set. 77 // set.
78 return _taskBefore.result.then((_) => pumpEventQueue()); 78 return _taskBefore.result.then((_) => pumpEventQueue());
79 }); 79 });
80 } 80 }
81 } 81 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/scheduled_future_matchers.dart ('k') | pkg/scheduled_test/lib/src/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698