Upgrading tests with unittest deprecations

R=ricow@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org//218273002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34569 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
kevmoo@google.com 2014-03-31 18:33:18 +00:00
parent 18f8f69400
commit 5952d7a067
76 changed files with 262 additions and 273 deletions

View file

@ -17,7 +17,7 @@ void main() {
test('performanceTesting', () {
Timer.run(BENCHMARK_SUITE.runBenchmarks);
Timer.run(expectAsync0(testForCompletion));
Timer.run(expectAsync(testForCompletion));
});
}

View file

@ -37,7 +37,7 @@ main() {
var url = canvas.toDataUrl();
var img = new ImageElement();
img.onLoad.listen(expectAsync1((_) {
img.onLoad.listen(expectAsync((_) {
expect(img.complete, true);
}));
img.onError.listen((_) {

View file

@ -339,7 +339,7 @@ main() {
var dataUrl = otherCanvas.toDataUrl('image/gif');
var img = new ImageElement();
img.onLoad.listen(expectAsync1((_) {
img.onLoad.listen(expectAsync((_) {
context.drawImage(img, 50, 50);
expectPixelFilled(50, 50);
@ -362,7 +362,7 @@ main() {
var dataUrl = otherCanvas.toDataUrl('image/gif');
var img = new ImageElement();
img.onLoad.listen(expectAsync1((_) {
img.onLoad.listen(expectAsync((_) {
context.drawImageToRect(img, new Rectangle(50, 50, 20, 20));
expectPixelFilled(50, 50);
@ -389,7 +389,7 @@ main() {
var dataUrl = otherCanvas.toDataUrl('image/gif');
var img = new ImageElement();
img.onLoad.listen(expectAsync1((_) {
img.onLoad.listen(expectAsync((_) {
// This will take a 6x6 square from the first canvas from position 2,2
// and then scale it to a 20x20 square and place it to the second
// canvas at 50,50.
@ -482,7 +482,7 @@ main() {
tearDown(tearDownFunc);
test('with 3 params', () {
video.onCanPlay.listen(expectAsync1((_) {
video.onCanPlay.listen(expectAsync((_) {
context.drawImage(video, 50, 50);
expectPixelFilled(50, 50);
@ -510,7 +510,7 @@ main() {
});
test('with 5 params', () {
video.onCanPlay.listen(expectAsync1((_) {
video.onCanPlay.listen(expectAsync((_) {
context.drawImageToRect(video, new Rectangle(50, 50, 20, 20));
expectPixelFilled(50, 50);
@ -540,7 +540,7 @@ main() {
});
test('with 9 params', () {
video.onCanPlay.listen(expectAsync1((_) {
video.onCanPlay.listen(expectAsync((_) {
context.drawImageToRect(video, new Rectangle(50, 50, 20, 20),
sourceRect: new Rectangle(2, 2, 6, 6));
@ -578,7 +578,7 @@ main() {
test('with 9 params', () {
video = new VideoElement();
canvas = new CanvasElement();
video.onCanPlay.listen(expectAsync1((_) {
video.onCanPlay.listen(expectAsync((_) {
context.drawImageToRect(video, new Rectangle(50, 50, 20, 20),
sourceRect: new Rectangle(2, 2, 6, 6));

View file

@ -86,7 +86,7 @@ main() {
document.body.children.add(element);
// Need to wait one tick after the element has been added to the page.
new Timer(const Duration(milliseconds: 10), expectAsync0(() {
new Timer(const Duration(milliseconds: 10), expectAsync(() {
element.style.textDecoration = 'underline';
var style = element.getComputedStyle();
expect(style.textDecoration, contains('underline'));

View file

@ -774,14 +774,14 @@ main() {
document.body.append(selectorOne);
document.body.append(selectorTwo);
document.body.onClick.matches('.selector').listen(expectAsync1(
document.body.onClick.matches('.selector').listen(expectAsync(
(Event event) {
expect(event.currentTarget, document.body);
expect(event.target, clickOne);
expect(event.matchingTarget, selectorOne);
}));
selectorOne.onClick.matches('.selector').listen(expectAsync1(
selectorOne.onClick.matches('.selector').listen(expectAsync(
(Event event) {
expect(event.currentTarget, selectorOne);
expect(event.target, clickOne);

View file

@ -143,7 +143,7 @@ main() {
test('DOMMutationEvent', () {
var div = new DivElement();
div.on['DOMSubtreeModified'].add(expectAsync1((DOMMutationEvent e) {}));
div.on['DOMSubtreeModified'].add(expectAsync((DOMMutationEvent e) {}));
div.append(new SpanElement());
});

View file

@ -96,8 +96,8 @@ main() {
document.body.append(element);
// runZoned executes the function synchronously, but we don't want to
// rely on this. We therefore wrap it into an expectAsync0.
runZoned(expectAsync0(() {
// rely on this. We therefore wrap it into an expectAsync.
runZoned(expectAsync(() {
Zone zone = Zone.current;
expect(zone, isNot(equals(Zone.ROOT)));
@ -106,13 +106,13 @@ main() {
void handler(Event e) {
expect(Zone.current, equals(zone));
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
expect(Zone.current, equals(zone));
sub.cancel();
}));
}
sub = element.on['test'].listen(expectAsync1(handler));
sub = element.on['test'].listen(expectAsync(handler));
}));
element.dispatchEvent(new Event('test'));
});

View file

@ -13,7 +13,7 @@ main() {
test('readAsText', () {
var reader = new FileReader();
reader.onLoad.listen(expectAsync1((event) {
reader.onLoad.listen(expectAsync((event) {
var result = reader.result;
expect(result, equals('hello world'));
}));
@ -22,7 +22,7 @@ main() {
test('readAsArrayBuffer', () {
var reader = new FileReader();
reader.onLoad.listen(expectAsync1((event) {
reader.onLoad.listen(expectAsync((event) {
var result = reader.result;
expect(result is Uint8List, isTrue);
expect(result, orderedEquals([65, 66, 67]));
@ -32,7 +32,7 @@ main() {
test('readDataUrl', () {
var reader = new FileReader();
reader.onLoad.listen(expectAsync1((event) {
reader.onLoad.listen(expectAsync((event) {
var result = reader.result;
expect(result is String, isTrue);
expect(result.startsWith('data:'), isTrue);

View file

@ -78,7 +78,7 @@ void main() {
xhr.open('POST',
'${window.location.protocol}//${window.location.host}/echo');
xhr.onLoad.listen(expectAsync1((e) {
xhr.onLoad.listen(expectAsync((e) {
expect(xhr.responseText.contains(blobString), true);
}));
xhr.onError.listen((e) {

View file

@ -43,8 +43,8 @@ main() {
expect(window.location.href.endsWith('dummy2'), isTrue);
// Need to wait a frame or two to let the pushState events occur.
new Timer(const Duration(milliseconds: 100), expectAsync0(() {
window.onPopState.first.then(expectAsync1((_){
new Timer(const Duration(milliseconds: 100), expectAsync(() {
window.onPopState.first.then(expectAsync((_){
expect(window.history.length, length);
expect(window.location.href.endsWith('dummy1'), isTrue);
}));

View file

@ -23,19 +23,19 @@ testReadWrite(key, value, check,
var db;
// Delete any existing DBs.
return html.window.indexedDB.deleteDatabase(dbName).then(expectAsync1((_) {
return html.window.indexedDB.deleteDatabase(dbName).then(expectAsync((_) {
return html.window.indexedDB.open(dbName, version: version,
onUpgradeNeeded: createObjectStore);
})).then(expectAsync1((result) {
})).then(expectAsync((result) {
db = result;
var transaction = db.transactionList([storeName], 'readwrite');
transaction.objectStore(storeName).put(value, key);
return transaction.completed;
})).then(expectAsync1((db) {
})).then(expectAsync((db) {
var transaction = db.transaction(storeName, 'readonly');
return transaction.objectStore(storeName).getObject(key);
})).then(expectAsync1((object) {
})).then(expectAsync((object) {
db.close();
check(value, object);
})).catchError((e) {

View file

@ -47,7 +47,7 @@ main() {
port.close();
});
test('NonDOMIsolates', () {
var callback = expectAsync0((){});
var callback = expectAsync((){});
var response = new isolate.ReceivePort();
var remote = isolate.Isolate.spawn(isolateEntry, response.sendPort);
response.first.then((port) {

View file

@ -31,7 +31,7 @@ main() {
test('constructKeyEvent', () {
var stream = KeyEvent.keyPressEvent.forTarget(document.body);
var subscription = stream.listen(expectAsync1((keyEvent) {
var subscription = stream.listen(expectAsync((keyEvent) {
expect(keyEvent.charCode, 97);
expect(keyEvent.keyCode, 65);
}));
@ -41,7 +41,7 @@ main() {
// Capital "A":
stream.add(new KeyEvent('keydown', keyCode: 16, charCode: 0));
subscription = stream.listen(expectAsync1((keyEvent) {
subscription = stream.listen(expectAsync((keyEvent) {
expect(keyEvent.charCode, 65);
expect(keyEvent.keyCode, 65);
}));
@ -56,17 +56,17 @@ main() {
var streamPress = KeyEvent.keyPressEvent.forTarget(document.body);
var streamUp = KeyEvent.keyUpEvent.forTarget(document.body);
var subscription = streamDown.listen(expectAsync1((keyEvent) {
var subscription = streamDown.listen(expectAsync((keyEvent) {
expect(keyEvent.keyCode, isIn([16, 191]));
expect(keyEvent.charCode, 0);
}, count: 2));
var subscription2 = streamPress.listen(expectAsync1((keyEvent) {
var subscription2 = streamPress.listen(expectAsync((keyEvent) {
expect(keyEvent.keyCode, 23);
expect(keyEvent.charCode, 63);
}));
var subscription3 = streamUp.listen(expectAsync1((keyEvent) {
var subscription3 = streamUp.listen(expectAsync((keyEvent) {
expect(keyEvent.keyCode, isIn([16, 191]));
expect(keyEvent.charCode, 0);
}, count: 2));
@ -84,7 +84,7 @@ main() {
});
test('KeyEventKeyboardEvent', () {
window.onKeyDown.listen(expectAsync1((KeyboardEvent event) {
window.onKeyDown.listen(expectAsync((KeyboardEvent event) {
expect(event.keyCode, 16);
}));
var streamDown = KeyEvent.keyDownEvent.forTarget(document.body);

View file

@ -47,7 +47,7 @@ main() {
triggerMajorGC();
}
testDiv.onClick.listen(expectAsync1((e) {}));
testDiv.onClick.listen(expectAsync((e) {}));
window.postMessage(message, '*');
});
}

View file

@ -12,14 +12,14 @@ main() {
test('oneShot', () {
var frame = window.requestAnimationFrame(
expectAsync1((timestamp) { }));
expectAsync((timestamp) { }));
});
test('twoShot', () {
var frame = window.requestAnimationFrame(
expectAsync1((timestamp1) {
expectAsync((timestamp1) {
window.requestAnimationFrame(
expectAsync1((timestamp2) {
expectAsync((timestamp2) {
// Not monotonic on Safari and IE.
// expect(timestamp2, greaterThan(timestamp1),
// reason: 'timestamps ordered');
@ -29,7 +29,7 @@ main() {
// How do we test that a callback is never called? We can't wrap the uncalled
// callback with 'expectAsync1'. Will request several frames and try
// callback with 'expectAsync'. Will request several frames and try
// cancelling the one that is not the last.
test('cancel1', () {
var frame1 = window.requestAnimationFrame(
@ -37,19 +37,19 @@ main() {
throw new Exception('Should have been cancelled');
});
var frame2 = window.requestAnimationFrame(
expectAsync1((timestamp2) { }));
expectAsync((timestamp2) { }));
window.cancelAnimationFrame(frame1);
});
test('cancel2', () {
var frame1 = window.requestAnimationFrame(
expectAsync1((timestamp1) { }));
expectAsync((timestamp1) { }));
var frame2 = window.requestAnimationFrame(
(timestamp2) {
throw new Exception('Should have been cancelled');
});
var frame3 = window.requestAnimationFrame(
expectAsync1((timestamp3) { }));
expectAsync((timestamp3) { }));
window.cancelAnimationFrame(frame2);
});
}

View file

@ -29,8 +29,8 @@ main() {
element.style.background = 'red';
element.style.transition = 'opacity .1s';
new Timer(const Duration(milliseconds: 100), expectAsync0(() {
element.onTransitionEnd.first.then(expectAsync1((e) {
new Timer(const Duration(milliseconds: 100), expectAsync(() {
element.onTransitionEnd.first.then(expectAsync((e) {
expect(e is TransitionEvent, isTrue);
expect(e.propertyName, 'opacity');
}));

View file

@ -42,7 +42,7 @@ main() {
expect(url, startsWith('blob:'));
var img = new ImageElement();
img.onLoad.listen(expectAsync1((_) {
img.onLoad.listen(expectAsync((_) {
expect(img.complete, true);
}));
img.onError.listen((_) {
@ -61,7 +61,7 @@ main() {
var img = new ImageElement();
// Image should fail to load since the URL was revoked.
img.onError.listen(expectAsync1((_) {
img.onError.listen(expectAsync((_) {
}));
img.onLoad.listen((_) {
guardAsync(() {

View file

@ -16,7 +16,7 @@ main() {
var element = new DivElement();
var eventType = Element.mouseWheelEvent.getEventType(element);
element.onMouseWheel.listen(expectAsync1((e) {
element.onMouseWheel.listen(expectAsync((e) {
expect(e.screen.x, 100);
expect(e.deltaX, 0);
expect(e.deltaY.toDouble(), 240.0);
@ -33,7 +33,7 @@ main() {
var element = new DivElement();
var eventType = Element.mouseWheelEvent.getEventType(element);
element.onMouseWheel.listen(expectAsync1((e) {
element.onMouseWheel.listen(expectAsync((e) {
expect(e.screen.x, 100);
expect(e.deltaX, 0);
expect(e.deltaY.toDouble(), 240.0);

View file

@ -27,6 +27,6 @@ main() {
var response = new ReceivePort();
var remote = Isolate.spawn(worker, ['', response.sendPort]);
remote.then((_) => response.first)
.then(expectAsync1((reply) => expect(reply, equals('Hello from Worker'))));
.then(expectAsync((reply) => expect(reply, equals('Hello from Worker'))));
});
}

View file

@ -37,7 +37,7 @@ main() {
var blob = new Blob([workerScript], 'text/javascript');
var url = Url.createObjectUrl(blob);
var worker = new Worker(url);
var test = expectAsync1((e) {
var test = expectAsync((e) {
expect(e.data, 'WorkerMessage');
});
worker.onMessage.first.then(test);

View file

@ -84,7 +84,7 @@ main() {
var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
var xhr = new HttpRequest();
xhr.open('GET', url, async: true);
var validate = expectAsync1((data) {
var validate = expectAsync((data) {
expect(data, contains('feed'));
expect(data['feed'], contains('entry'));
expect(data, isMap);

View file

@ -76,7 +76,7 @@ main() {
if (xhr.readyState == HttpRequest.DONE) {
validate200Response(xhr);
Timer.run(expectAsync0(() {
Timer.run(expectAsync(() {
expect(loadEndCalled, HttpRequest.supportsLoadEndEvent);
}));
}
@ -91,7 +91,7 @@ main() {
test('XHR.request No file', () {
HttpRequest.request('NonExistingFile').then(
(_) { fail('Request should not have succeeded.'); },
onError: expectAsync1((error) {
onError: expectAsync((error) {
var xhr = error.target;
expect(xhr.readyState, equals(HttpRequest.DONE));
validate404(xhr);
@ -99,7 +99,7 @@ main() {
});
test('XHR.request file', () {
HttpRequest.request(url).then(expectAsync1((xhr) {
HttpRequest.request(url).then(expectAsync((xhr) {
expect(xhr.readyState, equals(HttpRequest.DONE));
validate200Response(xhr);
}));
@ -110,7 +110,7 @@ main() {
HttpRequest.request(url,
onProgress: (_) {
progressCalled = true;
}).then(expectAsync1(
}).then(expectAsync(
(xhr) {
expect(xhr.readyState, equals(HttpRequest.DONE));
expect(progressCalled, HttpRequest.supportsProgressEvent);
@ -121,7 +121,7 @@ main() {
test('XHR.request withCredentials No file', () {
HttpRequest.request('NonExistingFile', withCredentials: true).then(
(_) { fail('Request should not have succeeded.'); },
onError: expectAsync1((error) {
onError: expectAsync((error) {
var xhr = error.target;
expect(xhr.readyState, equals(HttpRequest.DONE));
validate404(xhr);
@ -129,20 +129,20 @@ main() {
});
test('XHR.request withCredentials file', () {
HttpRequest.request(url, withCredentials: true).then(expectAsync1((xhr) {
HttpRequest.request(url, withCredentials: true).then(expectAsync((xhr) {
expect(xhr.readyState, equals(HttpRequest.DONE));
validate200Response(xhr);
}));
});
test('XHR.getString file', () {
HttpRequest.getString(url).then(expectAsync1((str) {}));
HttpRequest.getString(url).then(expectAsync((str) {}));
});
test('XHR.getString No file', () {
HttpRequest.getString('NonExistingFile').then(
(_) { fail('Succeeded for non-existing file.'); },
onError: expectAsync1((error) {
onError: expectAsync((error) {
validate404(error.target);
}));
});
@ -151,7 +151,7 @@ main() {
if (Platform.supportsTypedData) {
HttpRequest.request(url, responseType: 'arraybuffer',
requestHeaders: {'Content-Type': 'text/xml'}).then(
expectAsync1((xhr) {
expectAsync((xhr) {
expect(xhr.status, equals(200));
var byteBuffer = xhr.response;
expect(byteBuffer, new isInstanceOf<ByteBuffer>());
@ -239,7 +239,7 @@ main() {
method: 'POST',
sendData: JSON.encode(data),
responseType: 'json').then(
expectAsync1((xhr) {
expectAsync((xhr) {
expect(xhr.status, equals(200));
var json = xhr.response;
expect(json, equals(data));

View file

@ -26,7 +26,7 @@ void main([args, port]) {
document.body.append(script);
test('spawn with other script tags in page', () {
ReceivePort port = new ReceivePort();
port.listen(expectAsync1((msg) {
port.listen(expectAsync((msg) {
expect(msg, equals('re: hi'));
port.close();
}));

View file

@ -98,13 +98,13 @@ void main([args, port]) {
for (int i = 0; i < elements.length; i++) {
var sentObject = elements[i];
var idx = i;
sendReceive(remote, sentObject).then(expectAsync1((var receivedObject) {
sendReceive(remote, sentObject).then(expectAsync((var receivedObject) {
VerifyObject(idx, receivedObject);
}));
}
// Shutdown the MessageServer.
sendReceive(remote, -1).then(expectAsync1((int message) {
sendReceive(remote, -1).then(expectAsync((int message) {
expect(message, elements.length);
}));
});

View file

@ -31,7 +31,7 @@ void main([args, port]) {
Isolate.spawn(countMessages, local.sendPort);
SendPort remote;
int count = 0;
var done = expectAsync0((){});
var done = expectAsync((){});
local.listen((msg) {
switch (msg[0]) {
case "init":

View file

@ -40,7 +40,7 @@ void main([args, port]) {
test("send message cross isolates ", () {
ReceivePort fromIsolate1 = new ReceivePort();
Isolate.spawn(crossIsolate1, fromIsolate1.sendPort);
var done = expectAsync0((){});
var done = expectAsync((){});
fromIsolate1.listen((msg) {
switch (msg[0]) {
case "ready1":

View file

@ -27,7 +27,7 @@ void main([args, port]) {
Future spawn = Isolate.spawn(echo, port.sendPort);
var caught_exception = false;
var stream = port.asBroadcastStream();
stream.first.then(expectAsync1((snd) {
stream.first.then(expectAsync((snd) {
try {
snd.send(function);
} catch (e) {
@ -37,7 +37,7 @@ void main([args, port]) {
if (caught_exception) {
port.close();
} else {
stream.first.then(expectAsync1((msg) {
stream.first.then(expectAsync((msg) {
print("from worker ${msg}");
}));
}

View file

@ -32,7 +32,7 @@ void main([args, port]) {
Future spawn = Isolate.spawn(echo, port.sendPort);
var caught_exception = false;
var stream = port.asBroadcastStream();
stream.first.then(expectAsync1((snd) {
stream.first.then(expectAsync((snd) {
try {
snd.send(methodMirror);
} catch (e) {
@ -42,7 +42,7 @@ void main([args, port]) {
if (caught_exception) {
port.close();
} else {
stream.first.then(expectAsync1((msg) {
stream.first.then(expectAsync((msg) {
print("from worker ${msg}");
}));
}

View file

@ -15,8 +15,8 @@ void main([args, port]) {
test("complex messages are serialized correctly", () {
ReceivePort local = new ReceivePort();
Isolate.spawn(logMessages, local.sendPort);
var done = expectAsync0((){});
local.listen(expectAsync1((msg) {
var done = expectAsync((){});
local.listen(expectAsync((msg) {
switch (msg[0]) {
case "init":
var remote = msg[1];

View file

@ -20,7 +20,7 @@ void main([args, port]) {
configuration.timeout = const Duration(seconds: 480);
test("Render Mandelbrot in parallel", () {
final state = new MandelbrotState();
state._validated.future.then(expectAsync1((result) {
state._validated.future.then(expectAsync((result) {
expect(result, isTrue);
}));
for (int i = 0; i < min(ISOLATES, N); i++) state.startClient(i);

View file

@ -61,7 +61,7 @@ void main([args, port]) {
test("map is equal after it is sent back and forth", () {
ReceivePort port = new ReceivePort();
Isolate.spawn(pingPong, port.sendPort);
port.first.then(expectAsync1((remote) {
port.first.then(expectAsync((remote) {
Map m = new Map();
m[1] = "eins";
m[2] = "deux";
@ -69,7 +69,7 @@ void main([args, port]) {
m[4] = "four";
ReceivePort replyPort = new ReceivePort();
remote.send([m, replyPort.sendPort]);
replyPort.first.then(expectAsync1((var received) {
replyPort.first.then(expectAsync((var received) {
MessageTest.mapEqualsDeep(m, received);
remote.send(null);
}));

View file

@ -99,11 +99,11 @@ void main([args, port]) {
test("send objects and receive them back", () {
ReceivePort port = new ReceivePort();
Isolate.spawn(pingPong, port.sendPort);
port.first.then(expectAsync1((remote) {
port.first.then(expectAsync((remote) {
// Send objects and receive them back.
for (int i = 0; i < MessageTest.elms.length; i++) {
var sentObject = MessageTest.elms[i];
remoteCall(remote, sentObject).then(expectAsync1((var receivedObject) {
remoteCall(remote, sentObject).then(expectAsync((var receivedObject) {
MessageTest.VerifyObject(i, receivedObject);
}));
}
@ -133,7 +133,7 @@ void main([args, port]) {
});
// Shutdown the MessageServer.
remoteCall(remote, -1).then(expectAsync1((int message) {
remoteCall(remote, -1).then(expectAsync((int message) {
expect(message, MessageTest.elms.length + 1);
}));
}));

View file

@ -150,7 +150,7 @@ class MintMakerWrapper {
}
_checkBalance(PurseWrapper wrapper, expected) {
wrapper.queryBalance(expectAsync1((int balance) {
wrapper.queryBalance(expectAsync((int balance) {
expect(balance, equals(expected));
}));
}
@ -158,11 +158,11 @@ _checkBalance(PurseWrapper wrapper, expected) {
void main([args, port]) {
if (testRemote(main, port)) return;
test("creating purse, deposit, and query balance", () {
MintMakerWrapper.create().then(expectAsync1((mintMaker) {
mintMaker.makeMint(expectAsync1((MintWrapper mint) {
mint.createPurse(100, expectAsync1((PurseWrapper purse) {
MintMakerWrapper.create().then(expectAsync((mintMaker) {
mintMaker.makeMint(expectAsync((MintWrapper mint) {
mint.createPurse(100, expectAsync((PurseWrapper purse) {
_checkBalance(purse, 100);
purse.sproutPurse(expectAsync1((PurseWrapper sprouted) {
purse.sproutPurse(expectAsync((PurseWrapper sprouted) {
_checkBalance(sprouted, 0);
_checkBalance(purse, 100);

View file

@ -57,14 +57,14 @@ void main([args, port]) {
test("spawned isolate can spawn other isolates", () {
ReceivePort init = new ReceivePort();
Isolate.spawn(isolateA, init.sendPort);
init.first.then(expectAsync1((port) {
_call(port, "launch nested!", expectAsync2((msg, replyTo) {
init.first.then(expectAsync((port) {
_call(port, "launch nested!", expectAsync((msg, replyTo) {
expect(msg[0], "0");
_call(replyTo, msg1, expectAsync2((msg, replyTo) {
_call(replyTo, msg1, expectAsync((msg, replyTo) {
expect(msg[0], "2");
_call(replyTo, msg3, expectAsync2((msg, replyTo) {
_call(replyTo, msg3, expectAsync((msg, replyTo) {
expect(msg[0], "4");
_call(replyTo, msg5, expectAsync2((msg, _) {
_call(replyTo, msg5, expectAsync((msg, _) {
expect(msg[0], "6");
}));
}));

View file

@ -9,7 +9,7 @@
library PortTest;
import "package:expect/expect.dart";
import 'dart:isolate';
import '../../pkg/unittest/lib/matcher.dart';
import '../../pkg/matcher/lib/matcher.dart';
main() {
testHashCode();

View file

@ -25,7 +25,7 @@ main([args, port]) {
test("raw receive", () {
RawReceivePort port = new RawReceivePort();
Isolate.spawn(remote, port.sendPort);
port.handler = expectAsync1((v) {
port.handler = expectAsync((v) {
expect(v, "reply");
port.close();
});
@ -34,9 +34,9 @@ main([args, port]) {
test("raw receive twice - change handler", () {
RawReceivePort port = new RawReceivePort();
Isolate.spawn(remote2, port.sendPort);
port.handler = expectAsync1((v) {
port.handler = expectAsync((v) {
expect(v, "reply 1");
port.handler = expectAsync1((v) {
port.handler = expectAsync((v) {
expect(v, "reply 2");
port.close();
});
@ -46,18 +46,18 @@ main([args, port]) {
test("from-raw-port", () {
RawReceivePort rawPort = new RawReceivePort();
Isolate.spawn(remote, rawPort.sendPort);
rawPort.handler = expectAsync1((v) {
rawPort.handler = expectAsync((v) {
expect(v, "reply");
ReceivePort port = new ReceivePort.fromRawReceivePort(rawPort);
Isolate.spawn(remote, rawPort.sendPort);
Isolate.spawn(remote, port.sendPort);
int ctr = 2;
port.listen(expectAsync1((v) {
port.listen(expectAsync((v) {
expect(v, "reply");
ctr--;
if (ctr == 0) port.close();
}, count: 2),
onDone: expectAsync0((){}));
onDone: expectAsync((){}));
});
});
}

View file

@ -24,10 +24,10 @@ void main([args, port]) {
test("send", () {
ReceivePort init = new ReceivePort();
Isolate.spawn(entry, init.sendPort);
init.first.then(expectAsync1((port) {
init.first.then(expectAsync((port) {
ReceivePort reply = new ReceivePort();
port.send([99, reply.sendPort]);
reply.listen(expectAsync1((message) {
reply.listen(expectAsync((message) {
expect(message, 99 + 87);
reply.close();
}));

View file

@ -19,7 +19,7 @@ void main([args, port]) {
test('message - reply chain', () {
ReceivePort port = new ReceivePort();
Isolate.spawn(child, ['hi', port.sendPort]);
port.listen(expectAsync1((msg) {
port.listen(expectAsync((msg) {
port.close();
expect(msg, equals('re: hi'));
}));

View file

@ -17,7 +17,7 @@ import 'spawn_uri_child_isolate.dart';
main() {
test('isolate fromUri - negative test', () {
ReceivePort port = new ReceivePort();
port.first.then(expectAsync1((msg) {
port.first.then(expectAsync((msg) {
String expectedMessage = 're: hi';
// Should be hi, not hello.
expectedMessage = 're: hello'; /// 01: runtime error

View file

@ -15,6 +15,6 @@ main() {
ReceivePort port = new ReceivePort();
Isolate.spawnUri(Uri.parse('spawn_uri_nested_child1_vm_isolate.dart'),
[], [[1, 2], port.sendPort]);
port.first.then(expectAsync1((result) => print(result)));
port.first.then(expectAsync((result) => print(result)));
});
}

View file

@ -13,7 +13,7 @@ import '../../pkg/unittest/lib/unittest.dart';
main() {
test('isolate fromUri - send and reply', () {
ReceivePort port = new ReceivePort();
port.listen(expectAsync1((msg) {
port.listen(expectAsync((msg) {
expect(msg, equals('re: hi'));
port.close();
}));

View file

@ -13,7 +13,7 @@ import '../../pkg/unittest/lib/unittest.dart';
main() {
test('isolate fromUri - send and reply', () {
ReceivePort port = new ReceivePort();
port.first.then(expectAsync1((msg) {
port.first.then(expectAsync((msg) {
expect(msg, equals('re: hi'));
}));

View file

@ -11,7 +11,7 @@ void main([args, port]) {
test("stacktrace_message", () {
ReceivePort reply = new ReceivePort();
Isolate.spawn(runTest, reply.sendPort);
reply.first.then(expectAsync1((StackTrace stack) {
reply.first.then(expectAsync((StackTrace stack) {
print(stack);
}));
});

View file

@ -63,7 +63,7 @@ void spawnTest(name, function, response) {
test(name, () {
ReceivePort r = new ReceivePort();
Isolate.spawn(function, r.sendPort);
r.listen(expectAsync1((v) {
r.listen(expectAsync((v) {
expect(v, response);
r.close();
}));
@ -72,7 +72,7 @@ void spawnTest(name, function, response) {
void functionFailTest(name, function) {
test("throws on $name", () {
Isolate.spawn(function, null).catchError(expectAsync1((e) {
Isolate.spawn(function, null).catchError(expectAsync((e) {
/* do nothing */
}));
});

View file

@ -18,7 +18,7 @@ import "remote_unittest_helper.dart";
bethIsolate(init) {
ReceivePort port = initIsolate(init);
// TODO(sigmund): use expectAsync2 when it is OK to use it within an isolate
// TODO(sigmund): use expectAsync when it is OK to use it within an isolate
// (issue #6856)
port.first.then((msg) => msg[1].send([
'${msg[0]}\nBeth says: Tim are you coming? And Bob?', msg[2]]));
@ -54,7 +54,7 @@ ReceivePort initIsolate(SendPort starter) {
baseTest({bool failForNegativeTest: false}) {
test('Message chain with unresolved ports', () {
ReceivePort port = new ReceivePort();
port.listen(expectAsync1((msg) {
port.listen(expectAsync((msg) {
expect(msg, equals('main says: Beth, find out if Tim is coming.'
'\nBeth says: Tim are you coming? And Bob?'
'\nTim says: Can you tell "main" that we are all coming?'

View file

@ -26,6 +26,6 @@ main() {
new Stream.fromIterable([1, 2])
.transform(new DoubleTransformer())
.first
.then(expectAsync1((e) {}));
.then(expectAsync((e) {}));
});
}

View file

@ -12,7 +12,7 @@ main() {
Completer completer = new Completer();
Future timedOut = completer.future.timeout(
const Duration(milliseconds: 5), onTimeout: () => 42);
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(v, 42);
}));
});
@ -24,7 +24,7 @@ main() {
Timer timer = new Timer(const Duration(seconds: 1), () {
completer.complete(-1);
});
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(v, 42);
}));
});
@ -36,7 +36,7 @@ main() {
});
Future timedOut = completer.future.timeout(
const Duration(seconds: 1), onTimeout: () => -1);
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(v, 42);
}));
});
@ -46,7 +46,7 @@ main() {
completer.complete(42);
Future timedOut = completer.future.timeout(
const Duration(milliseconds: 5), onTimeout: () => -1);
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(v, 42);
}));
});
@ -55,7 +55,7 @@ main() {
Completer completer = new Completer();
Future timedOut = completer.future.timeout(
const Duration(milliseconds: 5), onTimeout: () { throw "EXN1"; });
timedOut.catchError(expectAsync2((e, s) {
timedOut.catchError(expectAsync((e, s) {
expect(e, "EXN1");
}));
});
@ -67,7 +67,7 @@ main() {
Timer timer = new Timer(const Duration(seconds: 1), () {
completer.completeError("EXN2");
});
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(v, 42);
}));
});
@ -79,7 +79,7 @@ main() {
});
Future timedOut = completer.future.timeout(
const Duration(seconds: 1), onTimeout: () => -1);
timedOut.catchError(expectAsync2((e, s) {
timedOut.catchError(expectAsync((e, s) {
expect(e, "EXN3");
}));
});
@ -90,7 +90,7 @@ main() {
completer.completeError("EXN4");
Future timedOut = completer.future.timeout(
const Duration(milliseconds: 5), onTimeout: () => -1);
timedOut.catchError(expectAsync2((e, s) {
timedOut.catchError(expectAsync((e, s) {
expect(e, "EXN4");
}));
});
@ -100,7 +100,7 @@ main() {
Completer completer = new Completer();
Future timedOut = completer.future.timeout(
const Duration(milliseconds: 5), onTimeout: () => result);
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(v, 42);
}));
});
@ -110,7 +110,7 @@ main() {
Completer completer = new Completer();
Future timedOut = completer.future.timeout(
const Duration(milliseconds: 5), onTimeout: () => result);
timedOut.catchError(expectAsync2((e, s) {
timedOut.catchError(expectAsync((e, s) {
expect(e, "EXN5");
}));
});
@ -123,7 +123,7 @@ main() {
result.complete(42);
return result.future;
});
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(v, 42);
}));
});
@ -136,7 +136,7 @@ main() {
result.completeError("EXN6");
return result.future;
});
timedOut.catchError(expectAsync2((e, s) {
timedOut.catchError(expectAsync((e, s) {
expect(e, "EXN6");
}));
});
@ -158,7 +158,7 @@ main() {
registerCallDelta++; // Increment calls to register.
expect(origin, forked);
expect(self, forked);
return expectAsync0(() { registerCallDelta--; return f(); });
return expectAsync(() { registerCallDelta--; return f(); });
}
));
Completer completer = new Completer();
@ -167,7 +167,7 @@ main() {
timedOut = completer.future.timeout(const Duration(milliseconds: 5),
onTimeout: callback);
});
timedOut.then(expectAsync1((v) {
timedOut.then(expectAsync((v) {
expect(callbackCalled, true);
expect(registerCallDelta, 0);
expect(Zone.current, initialZone);
@ -179,7 +179,7 @@ main() {
Completer completer = new Completer();
Future timedOut = completer.future.timeout(
const Duration(milliseconds: 5));
timedOut.catchError(expectAsync2((e, s) {
timedOut.catchError(expectAsync((e, s) {
expect(e, new isInstanceOf<TimeoutException>());
expect(e.duration, const Duration(milliseconds: 5));
expect(s, null);

View file

@ -63,12 +63,12 @@ main() {
_message = 0;
_stopwatch1.start();
new Timer(TIMEOUT1, expectAsync0(timeoutHandler1));
new Timer(TIMEOUT1, expectAsync(timeoutHandler1));
_stopwatch2.start();
new Timer(TIMEOUT2, expectAsync0(timeoutHandler2));
new Timer(TIMEOUT2, expectAsync(timeoutHandler2));
_stopwatch3.start();
new Timer(TIMEOUT3, expectAsync0(timeoutHandler3));
new Timer(TIMEOUT3, expectAsync(timeoutHandler3));
_stopwatch4.start();
new Timer(TIMEOUT4, expectAsync0(timeoutHandler4));
new Timer(TIMEOUT4, expectAsync(timeoutHandler4));
});
}

View file

@ -13,7 +13,7 @@ main() {
test("run async in order test", () {
int lastCallback = -1;
for (int i = 0; i < 100; i++) {
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.equals(lastCallback, i - 1);
lastCallback = i;
}));

View file

@ -13,13 +13,13 @@ main() {
// Check that Timers don't run before the async callbacks.
bool timerCallbackExecuted = false;
Timer.run(expectAsync0(() { timerCallbackExecuted = true; }));
Timer.run(expectAsync(() { timerCallbackExecuted = true; }));
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.isFalse(timerCallbackExecuted);
}));
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
// Busy loop.
var sum = 1;
var sw = new Stopwatch()..start();
@ -27,12 +27,12 @@ main() {
sum++;
}
if (sum == 0) throw "bad"; // Just to use the result.
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.isFalse(timerCallbackExecuted);
}));
}));
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.isFalse(timerCallbackExecuted);
}));
});

View file

@ -13,17 +13,17 @@ main() {
// Check that Timers don't run before the async callbacks.
bool timerCallbackExecuted = false;
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.isFalse(timerCallbackExecuted);
}));
Timer.run(expectAsync0(() { timerCallbackExecuted = true; }));
Timer.run(expectAsync(() { timerCallbackExecuted = true; }));
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.isFalse(timerCallbackExecuted);
}));
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
// Busy loop.
var sum = 1;
var sw = new Stopwatch()..start();
@ -31,12 +31,12 @@ main() {
sum++;
}
if (sum == 0) throw "bad"; // Just to use the result.
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.isFalse(timerCallbackExecuted);
}));
}));
scheduleMicrotask(expectAsync0(() {
scheduleMicrotask(expectAsync(() {
Expect.isFalse(timerCallbackExecuted);
}));
});

View file

@ -20,7 +20,7 @@ testController() {
StreamController c = new StreamController();
Stream stream = c.stream.asBroadcastStream(onCancel: cancelSub);
stream.fold(0, (a,b) => a + b)
.then(expectAsync1((int v) {
.then(expectAsync((int v) {
Expect.equals(42, v);
}));
c.add(10);
@ -32,7 +32,7 @@ testController() {
StreamController c = new StreamController();
Stream stream = c.stream.asBroadcastStream(onCancel: cancelSub);
stream.fold(0, (a,b) { throw "Fnyf!"; })
.catchError(expectAsync1((error) { Expect.equals("Fnyf!", error); }));
.catchError(expectAsync((error) { Expect.equals("Fnyf!", error); }));
c.add(42);
});
}
@ -42,7 +42,7 @@ testSingleController() {
StreamController c = new StreamController();
Stream stream = c.stream;
stream.fold(0, (a,b) => a + b)
.then(expectAsync1((int v) { Expect.equals(42, v); }));
.then(expectAsync((int v) { Expect.equals(42, v); }));
c.add(10);
c.add(32);
c.close();
@ -52,7 +52,7 @@ testSingleController() {
StreamController c = new StreamController();
Stream stream = c.stream;
stream.fold(0, (a,b) { throw "Fnyf!"; })
.catchError(expectAsync1((e) { Expect.equals("Fnyf!", e); }));
.catchError(expectAsync((e) { Expect.equals("Fnyf!", e); }));
c.add(42);
});
@ -70,7 +70,7 @@ testSingleController() {
(data) {
counter += data;
},
onDone: expectAsync0(() {
onDone: expectAsync(() {
Expect.equals(3, counter);
}));
});
@ -83,7 +83,7 @@ testExtraMethods() {
StreamController c = new StreamController();
Events actualEvents = new Events();
Future f = c.stream.forEach(actualEvents.add);
f.then(expectAsync1((_) {
f.then(expectAsync((_) {
actualEvents.close();
Expect.listEquals(sentEvents.events, actualEvents.events);
}));
@ -95,7 +95,7 @@ testExtraMethods() {
StreamController c = new StreamController();
Events actualEvents = new Events();
Future f = c.stream.forEach(actualEvents.add);
f.catchError(expectAsync1((error) {
f.catchError(expectAsync((error) {
Expect.equals("bad", error);
Expect.listEquals((new Events()..add(7)).events, actualEvents.events);
}));
@ -110,7 +110,7 @@ testExtraMethods() {
if (x == 9) throw "bad";
actualEvents.add(x);
});
f.catchError(expectAsync1((error) {
f.catchError(expectAsync((error) {
Expect.equals("bad", error);
Expect.listEquals((new Events()..add(7)).events, actualEvents.events);
}));
@ -120,21 +120,21 @@ testExtraMethods() {
test("firstWhere", () {
StreamController c = new StreamController();
Future f = c.stream.firstWhere((x) => (x % 3) == 0);
f.then(expectAsync1((v) { Expect.equals(9, v); }));
f.then(expectAsync((v) { Expect.equals(9, v); }));
sentEvents.replay(c);
});
test("firstWhere 2", () {
StreamController c = new StreamController();
Future f = c.stream.firstWhere((x) => (x % 4) == 0);
f.catchError(expectAsync1((e) {}));
f.catchError(expectAsync((e) {}));
sentEvents.replay(c);
});
test("firstWhere 3", () {
StreamController c = new StreamController();
Future f = c.stream.firstWhere((x) => (x % 4) == 0, defaultValue: () => 999);
f.then(expectAsync1((v) { Expect.equals(999, v); }));
f.then(expectAsync((v) { Expect.equals(999, v); }));
sentEvents.replay(c);
});
@ -142,49 +142,49 @@ testExtraMethods() {
test("lastWhere", () {
StreamController c = new StreamController();
Future f = c.stream.lastWhere((x) => (x % 3) == 0);
f.then(expectAsync1((v) { Expect.equals(87, v); }));
f.then(expectAsync((v) { Expect.equals(87, v); }));
sentEvents.replay(c);
});
test("lastWhere 2", () {
StreamController c = new StreamController();
Future f = c.stream.lastWhere((x) => (x % 4) == 0);
f.catchError(expectAsync1((e) {}));
f.catchError(expectAsync((e) {}));
sentEvents.replay(c);
});
test("lastWhere 3", () {
StreamController c = new StreamController();
Future f = c.stream.lastWhere((x) => (x % 4) == 0, defaultValue: () => 999);
f.then(expectAsync1((v) { Expect.equals(999, v); }));
f.then(expectAsync((v) { Expect.equals(999, v); }));
sentEvents.replay(c);
});
test("singleWhere", () {
StreamController c = new StreamController();
Future f = c.stream.singleWhere((x) => (x % 9) == 0);
f.then(expectAsync1((v) { Expect.equals(9, v); }));
f.then(expectAsync((v) { Expect.equals(9, v); }));
sentEvents.replay(c);
});
test("singleWhere 2", () {
StreamController c = new StreamController();
Future f = c.stream.singleWhere((x) => (x % 3) == 0); // Matches 9 and 87..
f.catchError(expectAsync1((error) { Expect.isTrue(error is StateError); }));
f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); }));
sentEvents.replay(c);
});
test("first", () {
StreamController c = new StreamController();
Future f = c.stream.first;
f.then(expectAsync1((v) { Expect.equals(7, v);}));
f.then(expectAsync((v) { Expect.equals(7, v);}));
sentEvents.replay(c);
});
test("first empty", () {
StreamController c = new StreamController();
Future f = c.stream.first;
f.catchError(expectAsync1((error) { Expect.isTrue(error is StateError); }));
f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); }));
Events emptyEvents = new Events()..close();
emptyEvents.replay(c);
});
@ -192,7 +192,7 @@ testExtraMethods() {
test("first error", () {
StreamController c = new StreamController();
Future f = c.stream.first;
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..error("error")..close();
errorEvents.replay(c);
});
@ -200,7 +200,7 @@ testExtraMethods() {
test("first error 2", () {
StreamController c = new StreamController();
Future f = c.stream.first;
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..error("error")..error("error2")..close();
errorEvents.replay(c);
});
@ -208,14 +208,14 @@ testExtraMethods() {
test("last", () {
StreamController c = new StreamController();
Future f = c.stream.last;
f.then(expectAsync1((v) { Expect.equals(87, v);}));
f.then(expectAsync((v) { Expect.equals(87, v);}));
sentEvents.replay(c);
});
test("last empty", () {
StreamController c = new StreamController();
Future f = c.stream.last;
f.catchError(expectAsync1((error) { Expect.isTrue(error is StateError); }));
f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); }));
Events emptyEvents = new Events()..close();
emptyEvents.replay(c);
});
@ -223,7 +223,7 @@ testExtraMethods() {
test("last error", () {
StreamController c = new StreamController();
Future f = c.stream.last;
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..error("error")..close();
errorEvents.replay(c);
});
@ -231,7 +231,7 @@ testExtraMethods() {
test("last error 2", () {
StreamController c = new StreamController();
Future f = c.stream.last;
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..error("error")..error("error2")..close();
errorEvents.replay(c);
});
@ -239,28 +239,28 @@ testExtraMethods() {
test("elementAt", () {
StreamController c = new StreamController();
Future f = c.stream.elementAt(2);
f.then(expectAsync1((v) { Expect.equals(13, v);}));
f.then(expectAsync((v) { Expect.equals(13, v);}));
sentEvents.replay(c);
});
test("elementAt 2", () {
StreamController c = new StreamController();
Future f = c.stream.elementAt(20);
f.catchError(expectAsync1((error) { Expect.isTrue(error is RangeError); }));
f.catchError(expectAsync((error) { Expect.isTrue(error is RangeError); }));
sentEvents.replay(c);
});
test("drain", () {
StreamController c = new StreamController();
Future f = c.stream.drain();
f.then(expectAsync1((v) { Expect.equals(null, v);}));
f.then(expectAsync((v) { Expect.equals(null, v);}));
sentEvents.replay(c);
});
test("drain error", () {
StreamController c = new StreamController();
Future f = c.stream.drain();
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..error("error")..error("error2")..close();
errorEvents.replay(c);
});
@ -367,7 +367,7 @@ testRethrow() {
test("rethrow-$name-value", () {
StreamController c = new StreamController();
Stream s = streamValueTransform(c.stream, (v) { throw error; });
s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync1(
s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync(
(e) { Expect.identical(error, e); }));
c.add(null);
c.close();
@ -378,7 +378,7 @@ testRethrow() {
test("rethrow-$name-error", () {
StreamController c = new StreamController();
Stream s = streamErrorTransform(c.stream, (e) { throw error; });
s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync1(
s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync(
(e) { Expect.identical(error, e); }));
c.addError(null);
c.close();
@ -390,7 +390,7 @@ testRethrow() {
StreamController c = new StreamController();
Future f = streamValueTransform(c.stream, (v) { throw error; });
f.then((v) { Expect.fail("unreachable"); },
onError: expectAsync1((e) { Expect.identical(error, e); }));
onError: expectAsync((e) { Expect.identical(error, e); }));
// Need two values to trigger compare for reduce.
c.add(0);
c.add(1);
@ -570,7 +570,7 @@ void testAsBroadcast() {
void testSink({bool sync, bool broadcast, bool asBroadcast}) {
String type = "${sync?"S":"A"}${broadcast?"B":"S"}${asBroadcast?"aB":""}";
test("$type-controller-sink", () {
var done = expectAsync0((){});
var done = expectAsync((){});
var c = broadcast ? new StreamController.broadcast(sync: sync)
: new StreamController(sync: sync);
var expected = new Events()
@ -594,7 +594,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
});
test("$type-controller-sink-canceled", () {
var done = expectAsync0((){});
var done = expectAsync((){});
var c = broadcast ? new StreamController.broadcast(sync: sync)
: new StreamController(sync: sync);
var expected = new Events()
@ -629,7 +629,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
});
test("$type-controller-sink-paused", () {
var done = expectAsync0((){});
var done = expectAsync((){});
var c = broadcast ? new StreamController.broadcast(sync: sync)
: new StreamController(sync: sync);
var expected = new Events()
@ -678,7 +678,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
test("$type-controller-addstream-error-stop", () {
// Check that addStream defaults to ending after the first error.
var done = expectAsync0((){});
var done = expectAsync((){});
StreamController c = broadcast
? new StreamController.broadcast(sync: sync)
: new StreamController(sync: sync);
@ -703,7 +703,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
test("$type-controller-addstream-error-forward", () {
// Check that addStream with cancelOnError:false passes all data and errors
// to the controller.
var done = expectAsync0((){});
var done = expectAsync((){});
StreamController c = broadcast
? new StreamController.broadcast(sync: sync)
: new StreamController(sync: sync);
@ -726,7 +726,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
test("$type-controller-addstream-twice", () {
// Using addStream twice on the same stream
var done = expectAsync0((){});
var done = expectAsync((){});
StreamController c = broadcast
? new StreamController.broadcast(sync: sync)
: new StreamController(sync: sync);

View file

@ -22,7 +22,7 @@ main() {
test("firstWhere with super class", () {
StreamController c = new StreamController<B>();
Future f = c.stream.firstWhere((x) => false, defaultValue: () => const A());
f.then(expectAsync1((v) { Expect.equals(const A(), v); }));
f.then(expectAsync((v) { Expect.equals(const A(), v); }));
sentEvents.replay(c);
});
}

View file

@ -19,7 +19,7 @@ class IterableTest<T> {
Events expected = new Events.fromIterable(iterable);
Stream<T> stream = new Stream<T>.fromIterable(iterable);
Events actual = new Events.capture(stream);
actual.onDone(expectAsync0(() {
actual.onDone(expectAsync(() {
Expect.listEquals(expected.events, actual.events);
}));
});
@ -39,7 +39,7 @@ main() {
Iterable<int> iter = new Iterable.generate(25, (i) => i * 2);
test("iterable-toList", () {
new Stream.fromIterable(iter).toList().then(expectAsync1((actual) {
new Stream.fromIterable(iter).toList().then(expectAsync((actual) {
List expected = iter.toList();
Expect.equals(25, expected.length);
Expect.listEquals(expected, actual);
@ -50,7 +50,7 @@ main() {
new Stream.fromIterable(iter)
.map((i) => i * 3)
.toList()
.then(expectAsync1((actual) {
.then(expectAsync((actual) {
List expected = iter.map((i) => i * 3).toList();
Expect.listEquals(expected, actual);
}));
@ -67,7 +67,7 @@ main() {
if (value == 20) {
subscription.pause(new Future.delayed(duration, () {}));
}
}, onDone: expectAsync0(() {
}, onDone: expectAsync(() {
actual.close();
Events expected = new Events.fromIterable(iter);
Expect.listEquals(expected.events, actual.events);
@ -89,7 +89,7 @@ main() {
var c = new StreamController();
var sink = c.sink;
var done = expectAsync0((){}, count: 2);
var done = expectAsync((){}, count: 2);
// if this goes first, test failed (hanged). Swapping addStream and toList
// made failure go away.
@ -113,7 +113,7 @@ main() {
var c = new StreamController();
var sink = c.sink;
var done = expectAsync0((){}, count: 2);
var done = expectAsync((){}, count: 2);
var data = [], errors = [];
c.stream.listen(data.add, onError: errors.add, onDone: () {
@ -135,7 +135,7 @@ main() {
var c = new StreamController();
var done = expectAsync0((){}, count: 2);
var done = expectAsync((){}, count: 2);
var data = [], errors = [];
c.stream.listen(data.add, onError: errors.add, onDone: () {

View file

@ -10,15 +10,15 @@ main() {
StreamController c = new StreamController();
Stream s = c.stream;
StreamIterator i = new StreamIterator(s);
i.moveNext().then(expectAsync1((bool b) {
i.moveNext().then(expectAsync((bool b) {
expect(b, isTrue);
expect(42, i.current);
return i.moveNext();
})).then(expectAsync1((bool b) {
})).then(expectAsync((bool b) {
expect(b, isTrue);
expect(37, i.current);
return i.moveNext();
})).then(expectAsync1((bool b) {
})).then(expectAsync((bool b) {
expect(b, isFalse);
}));
c.add(42);
@ -33,15 +33,15 @@ main() {
c.close();
Stream s = c.stream;
StreamIterator i = new StreamIterator(s);
i.moveNext().then(expectAsync1((bool b) {
i.moveNext().then(expectAsync((bool b) {
expect(b, isTrue);
expect(42, i.current);
return i.moveNext();
})).then(expectAsync1((bool b) {
})).then(expectAsync((bool b) {
expect(b, isTrue);
expect(37, i.current);
return i.moveNext();
})).then(expectAsync1((bool b) {
})).then(expectAsync((bool b) {
expect(b, isFalse);
}));
});
@ -50,16 +50,16 @@ main() {
StreamController c = new StreamController();
Stream s = c.stream;
StreamIterator i = new StreamIterator(s);
i.moveNext().then(expectAsync1((bool b) {
i.moveNext().then(expectAsync((bool b) {
expect(b, isTrue);
expect(42, i.current);
return i.moveNext();
})).then((bool b) {
fail("Result not expected");
}, onError: expectAsync1((e) {
}, onError: expectAsync((e) {
expect("BAD", e);
return i.moveNext();
})).then(expectAsync1((bool b) {
})).then(expectAsync((bool b) {
expect(b, isFalse);
}));
c.add(42);
@ -72,21 +72,21 @@ main() {
StreamController c = new StreamController();
Stream s = c.stream;
StreamIterator i = new StreamIterator(s);
i.moveNext().then(expectAsync1((bool b) {
i.moveNext().then(expectAsync((bool b) {
expect(b, isTrue);
expect(42, i.current);
new Timer(const Duration(milliseconds:100), expectAsync0(() {
new Timer(const Duration(milliseconds:100), expectAsync(() {
expect(i.current, null);
expect(() { i.moveNext(); }, throws);
c.add(37);
c.close();
}));
return i.moveNext();
})).then(expectAsync1((bool b) {
})).then(expectAsync((bool b) {
expect(b, isTrue);
expect(37, i.current);
return i.moveNext();
})).then(expectAsync1((bool b) {
})).then(expectAsync((bool b) {
expect(b, isFalse);
}));
c.add(42);

View file

@ -13,7 +13,7 @@ import "package:expect/expect.dart";
main() {
test("join-empty", () {
StreamController c = new StreamController();
c.stream.join("X").then(expectAsync1(
c.stream.join("X").then(expectAsync(
(String s) => expect(s, equals(""))
));
c.close();
@ -21,7 +21,7 @@ main() {
test("join-single", () {
StreamController c = new StreamController();
c.stream.join("X").then(expectAsync1(
c.stream.join("X").then(expectAsync(
(String s) => expect(s, equals("foo"))
));
c.add("foo");
@ -30,7 +30,7 @@ main() {
test("join-three", () {
StreamController c = new StreamController();
c.stream.join("X").then(expectAsync1(
c.stream.join("X").then(expectAsync(
(String s) => expect(s, equals("fooXbarXbaz"))
));
c.add("foo");
@ -41,7 +41,7 @@ main() {
test("join-three-non-string", () {
StreamController c = new StreamController();
c.stream.join("X").then(expectAsync1(
c.stream.join("X").then(expectAsync(
(String s) => expect(s, equals("fooXbarXbaz"))
));
c.add(new Foo("foo"));
@ -52,7 +52,7 @@ main() {
test("join-error", () {
StreamController c = new StreamController();
c.stream.join("X").catchError(expectAsync1(
c.stream.join("X").catchError(expectAsync(
(String s) => expect(s, equals("BAD!"))
));
c.add(new Foo("foo"));

View file

@ -22,7 +22,7 @@ main() {
test("lastWhere with super class", () {
StreamController c = new StreamController<B>();
Future f = c.stream.lastWhere((x) => false, defaultValue: () => const A());
f.then(expectAsync1((v) { Expect.equals(const A(), v); }));
f.then(expectAsync((v) { Expect.equals(const A(), v); }));
sentEvents.replay(c);
});
}

View file

@ -14,7 +14,7 @@ main() {
(x) => x);
int receivedCount = 0;
var subscription;
subscription = stream.listen(expectAsync1((data) {
subscription = stream.listen(expectAsync((data) {
expect(data, receivedCount);
receivedCount++;
if (receivedCount == 5) subscription.cancel();

View file

@ -19,7 +19,7 @@ main() {
Stopwatch watch = new Stopwatch()..start();
Stream stream = new Stream.periodic(const Duration(milliseconds: 1),
(x) => x);
stream.take(10).listen((_) { }, onDone: expectAsync0(() {
stream.take(10).listen((_) { }, onDone: expectAsync(() {
int millis = watch.elapsedMilliseconds + safetyMargin;
expect(millis, greaterThan(10));
}));

View file

@ -9,7 +9,7 @@ import "dart:async";
import '../../../pkg/unittest/lib/unittest.dart';
void runTest(period, maxElapsed, pauseDuration) {
Function done = expectAsync0(() { });
Function done = expectAsync(() { });
Stopwatch watch = new Stopwatch()..start();
Stream stream = new Stream.periodic(period, (x) => x);

View file

@ -39,6 +39,6 @@ main() {
subscription.resume();
});
}
}, onDone: expectAsync0(() { }));
}, onDone: expectAsync(() { }));
});
}

View file

@ -13,7 +13,7 @@ main() {
Stream stream = new Stream.periodic(const Duration(milliseconds: 1));
int receivedCount = 0;
var subscription;
subscription = stream.listen(expectAsync1((data) {
subscription = stream.listen(expectAsync((data) {
expect(data, isNull);
receivedCount++;
if (receivedCount == 5) subscription.cancel();

View file

@ -15,21 +15,21 @@ main() {
test("single", () {
StreamController c = new StreamController(sync: true);
Future f = c.stream.single;
f.then(expectAsync1((v) { Expect.equals(42, v);}));
f.then(expectAsync((v) { Expect.equals(42, v);}));
new Events.fromIterable([42]).replay(c);
});
test("single empty", () {
StreamController c = new StreamController(sync: true);
Future f = c.stream.single;
f.catchError(expectAsync1((error) { Expect.isTrue(error is StateError); }));
f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); }));
new Events.fromIterable([]).replay(c);
});
test("single error", () {
StreamController c = new StreamController(sync: true);
Future f = c.stream.single;
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..error("error")..close();
errorEvents.replay(c);
});
@ -37,7 +37,7 @@ main() {
test("single error 2", () {
StreamController c = new StreamController(sync: true);
Future f = c.stream.single;
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..error("error")..error("error2")..close();
errorEvents.replay(c);
});
@ -45,7 +45,7 @@ main() {
test("single error 3", () {
StreamController c = new StreamController(sync: true);
Future f = c.stream.single;
f.catchError(expectAsync1((error) { Expect.equals("error", error); }));
f.catchError(expectAsync((error) { Expect.equals("error", error); }));
Events errorEvents = new Events()..add(499)..error("error")..close();
errorEvents.replay(c);
});

View file

@ -16,8 +16,8 @@ main() {
StreamController c = new StreamController<int>(sync: true);
Stream<int> multi = c.stream.asBroadcastStream();
// Listen twice.
multi.listen(expectAsync1((v) => Expect.equals(42, v)));
multi.listen(expectAsync1((v) => Expect.equals(42, v)));
multi.listen(expectAsync((v) => Expect.equals(42, v)));
multi.listen(expectAsync((v) => Expect.equals(42, v)));
c.add(42);
});
@ -27,10 +27,10 @@ main() {
Events expected = new Events.fromIterable([1, 2, 3, 4, 5]);
Events actual1 = new Events.capture(multi);
Events actual2 = new Events.capture(multi);
actual1.onDone(expectAsync0(() {
actual1.onDone(expectAsync(() {
Expect.listEquals(expected.events, actual1.events);
}));
actual2.onDone(expectAsync0(() {
actual2.onDone(expectAsync(() {
Expect.listEquals(expected.events, actual2.events);
}));
expected.replay(c);
@ -42,10 +42,10 @@ main() {
Events expected = new Events.fromIterable([1, 2, 3, 4, 5]);
Events actual1 = new Events.capture(multi);
Events actual2 = new Events.capture(multi);
actual1.onDone(expectAsync0(() {
actual1.onDone(expectAsync(() {
Expect.listEquals(expected.events, actual1.events);
}));
actual2.onDone(expectAsync0(() {
actual2.onDone(expectAsync(() {
Expect.listEquals(expected.events, actual2.events);
}));
expected.replay(c);

View file

@ -64,7 +64,7 @@ class StreamProtocolTest {
onListen: _onListen,
onCancel: _onCancel);
_controllerStream = _controller.stream;
_onComplete = expectAsync0((){
_onComplete = expectAsync((){
_onComplete = null; // Being null marks the test as being complete.
});
}
@ -78,7 +78,7 @@ class StreamProtocolTest {
onResume: _onResume,
onCancel: _onCancel);
_controllerStream = _controller.stream;
_onComplete = expectAsync0((){
_onComplete = expectAsync((){
_onComplete = null; // Being null marks the test as being complete.
});
}
@ -94,7 +94,7 @@ class StreamProtocolTest {
_controllerStream = _controller.stream.asBroadcastStream(
onListen: _onBroadcastListen,
onCancel: _onBroadcastCancel);
_onComplete = expectAsync0((){
_onComplete = expectAsync((){
_onComplete = null; // Being null marks the test as being complete.
});
}
@ -373,11 +373,11 @@ class Event {
Function _action;
StackTrace _stackTrace;
Event(void action())
: _action = (action == null) ? null : expectAsync0(action) {
: _action = (action == null) ? null : expectAsync(action) {
try { throw 0; } catch (_, s) { _stackTrace = s; }
}
Event.broadcast(void action(StreamSubscription sub))
: _action = (action == null) ? null : expectAsync1(action) {
: _action = (action == null) ? null : expectAsync(action) {
try { throw 0; } catch (_, s) { _stackTrace = s; }
}

View file

@ -14,7 +14,7 @@ main() {
Stream stream = new Stream.fromIterable([1, 2, 3]);
var output = [];
var subscription = stream.listen((x) { output.add(x); });
subscription.asFuture(output).then(expectAsync1((o) {
subscription.asFuture(output).then(expectAsync((o) {
Expect.listEquals([1, 2, 3], o);
}));
});
@ -26,7 +26,7 @@ main() {
Stream stream = controller.stream;
var output = [];
var subscription = stream.listen((x) { output.add(x); });
subscription.asFuture(output).then(expectAsync1((o) {
subscription.asFuture(output).then(expectAsync((o) {
Expect.listEquals([1, 2, 3], o);
}));
});
@ -35,7 +35,7 @@ main() {
Stream stream = new Stream.fromIterable([1, 2, 3]).map((x) => x);
var output = [];
var subscription = stream.listen((x) { output.add(x); });
subscription.asFuture(output).then(expectAsync1((o) {
subscription.asFuture(output).then(expectAsync((o) {
Expect.listEquals([1, 2, 3], o);
}));
});
@ -48,7 +48,7 @@ main() {
Stream stream = controller.stream;
var output = [];
var subscription = stream.listen((x) { output.add(x); });
subscription.asFuture(output).catchError(expectAsync1((error) {
subscription.asFuture(output).catchError(expectAsync((error) {
Expect.equals(error, "foo");
}));
});
@ -61,7 +61,7 @@ main() {
});
var output = [];
var subscription = stream.listen((x) { output.add(x); });
subscription.asFuture(output).catchError(expectAsync1((error) {
subscription.asFuture(output).catchError(expectAsync((error) {
Expect.equals(error, "foo");
}));
});

View file

@ -13,7 +13,7 @@ main() {
StreamController c = new StreamController();
Stream tos = c.stream.timeout(ms5);
expect(tos.isBroadcast, false);
tos.handleError(expectAsync2((e, s) {
tos.handleError(expectAsync((e, s) {
expect(e, new isInstanceOf<TimeoutException>());
expect(s, null);
})).listen((v){ fail("Unexpected event"); });
@ -27,9 +27,9 @@ main() {
sink.close();
});
expect(tos.isBroadcast, false);
tos.listen(expectAsync1((v) { expect(v, 42); }),
onError: expectAsync2((e, s) { expect(e, "ERROR"); }),
onDone: expectAsync0((){}));
tos.listen(expectAsync((v) { expect(v, 42); }),
onError: expectAsync((e, s) { expect(e, "ERROR"); }),
onDone: expectAsync((){}));
});
test("stream no timeout", () {
@ -41,7 +41,7 @@ main() {
ctr++;
},
onError: (e, s) { fail("No error expected"); },
onDone: expectAsync0(() {
onDone: expectAsync(() {
expect(ctr, 2);
}));
expect(tos.isBroadcast, false);
@ -57,7 +57,7 @@ main() {
expect(v, 42);
ctr++;
},
onError: expectAsync2((e, s) {
onError: expectAsync((e, s) {
expect(ctr, 2);
expect(e, new isInstanceOf<TimeoutException>());
}));
@ -68,7 +68,7 @@ main() {
StreamController c = new StreamController.broadcast();
Stream tos = c.stream.timeout(ms5);
expect(tos.isBroadcast, false);
tos.handleError(expectAsync2((e, s) {
tos.handleError(expectAsync((e, s) {
expect(e, new isInstanceOf<TimeoutException>());
expect(s, null);
})).listen((v){ fail("Unexpected event"); });
@ -78,7 +78,7 @@ main() {
StreamController c = new StreamController.broadcast();
Stream tos = c.stream.asBroadcastStream().timeout(ms5);
expect(tos.isBroadcast, false);
tos.handleError(expectAsync2((e, s) {
tos.handleError(expectAsync((e, s) {
expect(e, new isInstanceOf<TimeoutException>());
expect(s, null);
})).listen((v){ fail("Unexpected event"); });
@ -88,7 +88,7 @@ main() {
StreamController c = new StreamController();
Stream tos = c.stream.map((x) => 2 * x).timeout(ms5);
expect(tos.isBroadcast, false);
tos.handleError(expectAsync2((e, s) {
tos.handleError(expectAsync((e, s) {
expect(e, new isInstanceOf<TimeoutException>());
expect(s, null);
})).listen((v){ fail("Unexpected event"); });
@ -121,7 +121,7 @@ main() {
});
sw.start();
tos.listen((v) { expect(v, 42);}, onDone: expectAsync0((){}));
tos.listen((v) { expect(v, 42);}, onDone: expectAsync((){}));
});
test("errors prevent timeout", () {
@ -155,7 +155,7 @@ main() {
onError: (e, s) {
expect(e, "ERROR");
},
onDone: expectAsync0((){}));
onDone: expectAsync((){}));
});
test("closing prevents timeout", () {
@ -163,7 +163,7 @@ main() {
Stream tos = c.stream.timeout(twoSecs, onTimeout: (_) {
fail("Timeout not prevented by close");
});
tos.listen((_) {}, onDone: expectAsync0((){}));
tos.listen((_) {}, onDone: expectAsync((){}));
c.close();
});
@ -172,7 +172,7 @@ main() {
Stream tos = c.stream.timeout(ms5, onTimeout: (_) {
fail("Timeout not prevented by close");
});
var subscription = tos.listen((_) {}, onDone: expectAsync0((){}));
var subscription = tos.listen((_) {}, onDone: expectAsync((){}));
subscription.pause();
new Timer(twoSecs, () {
c.close();

View file

@ -16,7 +16,7 @@ main() {
test("simpleDone", () {
StreamController c = new StreamController(sync: true);
Stream out = c.stream.handleError((x){}).handleError((x){});
out.listen((v){}, onDone: expectAsync0(() {}));
out.listen((v){}, onDone: expectAsync(() {}));
// Should not throw.
c.close();
});
@ -27,7 +27,7 @@ main() {
Events input = new Events.fromIterable([1, 2, 3, 4, 5, 6, 7]);
Events actual = new Events.capture(
c.stream.map((x) => x * 2).where((x) => x > 5).skip(2).take(2));
actual.onDone(expectAsync0(() {
actual.onDone(expectAsync(() {
Expect.listEquals(expected.events, actual.events);
}));
input.replay(c);
@ -39,7 +39,7 @@ main() {
Events input = new Events.fromIterable([1, 2, 3, 4, 5, 6, 7]);
Events actual = new Events.capture(
c.stream.map((x) => x * 2).where((x) => x > 5).skip(2).take(2));
actual.onDone(expectAsync0(() {
actual.onDone(expectAsync(() {
Expect.listEquals(expected.events, actual.events);
}));
actual.pause();
@ -53,7 +53,7 @@ main() {
.transform(new StreamTransformer.fromHandlers(
handleData: (element, sink) { sink.add(element); },
handleDone: (sink) { sink.close(); }))
.listen(expectAsync1((e) => expect(e, equals("foo"))));
.listen(expectAsync((e) => expect(e, equals("foo"))));
controller.add("foo");
// Should not crash.

View file

@ -21,8 +21,8 @@ main() {
}
cancelerTimer = new Timer(const Duration(milliseconds: 1),
expectAsync0(handler));
expectAsync(handler));
canceleeTimer = new Timer(const Duration(milliseconds: 1000),
expectAsync0(unreachable, count: 0));
expectAsync(unreachable, count: 0));
});
}

View file

@ -17,6 +17,6 @@ main() {
}
cancelTimer = new Timer.periodic(const Duration(milliseconds: 1),
expectAsync1(cancelHandler));
expectAsync(cancelHandler));
});
}

View file

@ -28,17 +28,17 @@ main() {
expect(repeatTimer, 1);
}
cancelTimer = new Timer(ms * 1000, expectAsync0(unreachable, count: 0));
cancelTimer = new Timer(ms * 1000, expectAsync(unreachable, count: 0));
cancelTimer.cancel();
new Timer(ms * 1000, expectAsync0(handler));
cancelTimer = new Timer(ms * 2000, expectAsync0(unreachable, count: 0));
new Timer(ms * 1000, expectAsync(handler));
cancelTimer = new Timer(ms * 2000, expectAsync(unreachable, count: 0));
repeatTimer = 0;
new Timer.periodic(ms * 1500, expectAsync1(repeatHandler));
new Timer.periodic(ms * 1500, expectAsync(repeatHandler));
});
test("cancel timer with same time", () {
var t2;
var t1 = new Timer(ms * 0, expectAsync0(() => t2.cancel()));
t2 = new Timer(ms * 0, expectAsync0(t1.cancel, count: 0));
var t1 = new Timer(ms * 0, expectAsync(() => t2.cancel()));
t2 = new Timer(ms * 0, expectAsync(t1.cancel, count: 0));
});
}

View file

@ -11,7 +11,7 @@ main() {
Timer t;
t = new Timer(const Duration(seconds: 1),
expectAsync0(() => expect(t.isActive, equals(false))));
expectAsync(() => expect(t.isActive, equals(false))));
expect(t.isActive, equals(true));
});
@ -29,14 +29,14 @@ main() {
}
t = new Timer.periodic(new Duration(milliseconds: 1),
expectAsync1(checkActive, count: 3));
expectAsync(checkActive, count: 3));
expect(t.isActive, equals(true));
});
test("timer cancel test", () {
Timer timer = new Timer(const Duration(seconds: 1),
() => fail("Should not be reached."));
Timer.run(expectAsync0(() {
Timer.run(expectAsync(() {
expect(timer.isActive, equals(true));
timer.cancel();
expect(timer.isActive, equals(false));

View file

@ -28,7 +28,7 @@ main() {
ReceivePort port = new ReceivePort();
port.first.then(expectAsync1((msg) {
port.first.then(expectAsync((msg) {
expect("timer_fired", msg);
int endTime = (new DateTime.now()).millisecondsSinceEpoch;
expect(endTime - startTime + safetyMargin, greaterThanOrEqualTo(TIMEOUT.inMilliseconds));

View file

@ -30,6 +30,6 @@ main() {
iteration = 0;
startTime = new DateTime.now().millisecondsSinceEpoch;
timer = new Timer.periodic(TIMEOUT,
expectAsync1(timeoutHandler, count: ITERATIONS));
expectAsync(timeoutHandler, count: ITERATIONS));
});
}

View file

@ -28,7 +28,7 @@ void timeoutHandler() {
timeout = timeout - DECREASE;
Duration duration = new Duration(milliseconds: timeout);
startTime = (new DateTime.now()).millisecondsSinceEpoch;
new Timer(duration, expectAsync0(timeoutHandler));
new Timer(duration, expectAsync(timeoutHandler));
}
}
@ -38,6 +38,6 @@ main() {
timeout = STARTTIMEOUT;
Duration duration = new Duration(milliseconds: timeout);
startTime = (new DateTime.now()).millisecondsSinceEpoch;
new Timer(duration, expectAsync0(timeoutHandler));
new Timer(duration, expectAsync(timeoutHandler));
});
}

View file

@ -55,14 +55,3 @@ equals(expected) {
get throws => new Expectation((actual) => Expect.throws(actual));
get isTrue => new Expectation((actual) => Expect.isTrue(actual));
expectAsync1(then) {
asyncStart();
return (x) {
// 'then(x)' may call 'asyncStart()', so we first need to execute it, before
// we can call 'asyncEnd()'.
var result = then(x);
asyncEnd();
return result;
};
}