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

Side by Side Diff: pkg/unittest/test/returning_future_test.dart

Issue 524153002: Sharing metatest logic between unittest and scheduled_test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: status fixes Created 6 years, 3 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 | 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 unittestTest; 5 library unittest.returning_future_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:isolate';
9 8
9 import 'package:metatest/metatest.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 part 'utils.dart'; 12 void main() => initTests(_test);
13 13
14 var testName = 'test returning future'; 14 void _test(message) {
15 initMetatest(message);
15 16
16 var testFunction = (_) { 17 expectTestResults('returning futures', () {
17 test("successful", () { 18 test("successful", () {
18 return _defer(() { 19 return new Future.sync(() {
19 expect(true, true); 20 expect(true, true);
21 });
20 }); 22 });
21 }); 23 // We repeat the fail and error tests, because during development
22 // We repeat the fail and error tests, because during development 24 // I had a situation where either worked fine on their own, and
23 // I had a situation where either worked fine on their own, and 25 // error/fail worked, but fail/error would time out.
24 // error/fail worked, but fail/error would time out. 26 test("error1", () {
25 test("error1", () { 27 var callback = expectAsync(() {});
26 var callback = expectAsync(() {}); 28 var excesscallback = expectAsync(() {});
27 var excesscallback = expectAsync(() {}); 29 return new Future.sync(() {
28 return _defer(() { 30 excesscallback();
29 excesscallback(); 31 excesscallback();
30 excesscallback(); 32 excesscallback();
31 excesscallback(); 33 callback();
32 callback(); 34 });
33 }); 35 });
34 }); 36 test("fail1", () {
35 test("fail1", () { 37 return new Future.sync(() {
36 return _defer(() { 38 expect(true, false);
37 expect(true, false); 39 });
38 }); 40 });
39 }); 41 test("error2", () {
40 test("error2", () { 42 var callback = expectAsync(() {});
41 var callback = expectAsync(() {}); 43 var excesscallback = expectAsync(() {});
42 var excesscallback = expectAsync(() {}); 44 return new Future.sync(() {
43 return _defer(() { 45 excesscallback();
44 excesscallback(); 46 excesscallback();
45 excesscallback(); 47 callback();
46 callback(); 48 });
47 }); 49 });
48 }); 50 test("fail2", () {
49 test("fail2", () { 51 return new Future.sync(() {
50 return _defer(() { 52 fail('failure');
51 fail('failure'); 53 });
52 }); 54 });
53 }); 55 test('foo5', () {
54 test('foo5', () { 56 });
55 }); 57 }, [{
56 }; 58 'result': 'pass'
57 59 }, {
58 var expected = buildStatusString(2, 4, 0, 60 'result': 'fail',
59 'successful::' 61 'message': 'Callback called more times than expected (1).'
60 'error1:Callback called more times than expected (1).:' 62 }, {
61 'fail1:Expected: <false> Actual: <true>:' 63 'result': 'fail',
62 'error2:Callback called more times than expected (1).:' 64 'message': 'Expected: <false>\n Actual: <true>\n'
63 'fail2:failure:' 65 }, {
64 'foo5'); 66 'result': 'fail',
67 'message': 'Callback called more times than expected (1).'
68 }, {
69 'result': 'fail',
70 'message': 'failure'
71 }, {
72 'result': 'pass'
73 }]);
74 }
OLDNEW
« no previous file with comments | « pkg/unittest/test/protect_async_test.dart ('k') | pkg/unittest/test/returning_future_using_runasync_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698