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

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: consolidated meta test method 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
7 import 'dart:async';
8 import 'dart:isolate';
9 6
10 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
11 8
12 part 'utils.dart'; 9 import 'package:metatest/metatest.dart';
13 10
14 var testName = 'test returning future'; 11 void main() => initTests(_test);
15 12
16 var testFunction = (_) { 13 void _test(message) {
17 test("successful", () { 14 initMetatest(message);
18 return _defer(() { 15
19 expect(true, true); 16 expectTestResults('returning futures', () {
17 test("successful", () {
18 return defer(() {
19 expect(true, true);
20 });
20 }); 21 });
21 }); 22 // We repeat the fail and error tests, because during development
22 // We repeat the fail and error tests, because during development 23 // 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 24 // error/fail worked, but fail/error would time out.
24 // error/fail worked, but fail/error would time out. 25 test("error1", () {
25 test("error1", () { 26 var callback = expectAsync(() {});
26 var callback = expectAsync(() {}); 27 var excesscallback = expectAsync(() {});
27 var excesscallback = expectAsync(() {}); 28 return defer(() {
28 return _defer(() { 29 excesscallback();
29 excesscallback(); 30 excesscallback();
30 excesscallback(); 31 excesscallback();
31 excesscallback(); 32 callback();
32 callback(); 33 });
33 }); 34 });
34 }); 35 test("fail1", () {
35 test("fail1", () { 36 return defer(() {
36 return _defer(() { 37 expect(true, false);
37 expect(true, false); 38 });
38 }); 39 });
39 }); 40 test("error2", () {
40 test("error2", () { 41 var callback = expectAsync(() {});
41 var callback = expectAsync(() {}); 42 var excesscallback = expectAsync(() {});
42 var excesscallback = expectAsync(() {}); 43 return defer(() {
43 return _defer(() { 44 excesscallback();
44 excesscallback(); 45 excesscallback();
45 excesscallback(); 46 callback();
46 callback(); 47 });
47 }); 48 });
48 }); 49 test("fail2", () {
49 test("fail2", () { 50 return defer(() {
50 return _defer(() { 51 fail('failure');
51 fail('failure'); 52 });
52 }); 53 });
53 }); 54 test('foo5', () {
54 test('foo5', () { 55 });
55 }); 56 }, [{
56 }; 57 'result': 'pass'
57 58 }, {
58 var expected = buildStatusString(2, 4, 0, 59 'result': 'fail',
59 'successful::' 60 'message': 'Callback called more times than expected (1).'
60 'error1:Callback called more times than expected (1).:' 61 }, {
61 'fail1:Expected: <false> Actual: <true>:' 62 'result': 'fail',
62 'error2:Callback called more times than expected (1).:' 63 'message': 'Expected: <false>\n Actual: <true>\n'
63 'fail2:failure:' 64 }, {
64 'foo5'); 65 'result': 'fail',
66 'message': 'Callback called more times than expected (1).'
67 }, {
68 'result': 'fail',
69 'message': 'failure'
70 }, {
71 'result': 'pass'
72 }]);
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698