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

Side by Side Diff: pkg/unittest/test/expect_async_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
« no previous file with comments | « pkg/unittest/test/expect_async_args_test.dart ('k') | pkg/unittest/test/group_name_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.expect_async_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 testFunction = (TestConfiguration testConfig) { 14 void _test(message) {
15 test('expectAsync zero params', () { 15 initMetatest(message);
16 _defer(expectAsync(() {
17 ++testConfig.count;
18 }));
19 });
20 16
21 test('expectAsync 1 param', () { 17 var count = 0;
22 var func = expectAsync((arg) {
23 expect(arg, 0);
24 ++testConfig.count;
25 });
26 _defer(() => func(0));
27 });
28 18
29 test('expectAsync 2 param', () { 19 expectTestsPass('expect async test', () {
30 var func = expectAsync((arg0, arg1) { 20 test('expectAsync zero params', () {
31 expect(arg0, 0); 21 new Future.sync(expectAsync(() {
32 expect(arg1, 1); 22 ++count;
33 ++testConfig.count; 23 }));
34 });
35 _defer(() => func(0, 1));
36 });
37
38 test('single arg to Future.catchError', () {
39 var func = expectAsync((error) {
40 expect(error, isStateError);
41 ++testConfig.count;
42 }); 24 });
43 25
44 new Future(() { 26 test('expectAsync 1 param', () {
45 throw new StateError('test'); 27 var func = expectAsync((arg) {
46 }).catchError(func); 28 expect(arg, 0);
47 }); 29 ++count;
48 30 });
49 test('2 args to Future.catchError', () { 31 new Future.sync(() => func(0));
50 var func = expectAsync((error, stack) {
51 expect(error, isStateError);
52 expect(stack is StackTrace, isTrue);
53 ++testConfig.count;
54 }); 32 });
55 33
56 new Future(() { 34 test('expectAsync 2 param', () {
57 throw new StateError('test'); 35 var func = expectAsync((arg0, arg1) {
58 }).catchError(func); 36 expect(arg0, 0);
59 }); 37 expect(arg1, 1);
60 38 ++count;
61 test('zero of two optional positional args', () { 39 });
62 var func = expectAsync(([arg0 = true, arg1 = true]) { 40 new Future.sync(() => func(0, 1));
63 expect(arg0, isTrue);
64 expect(arg1, isTrue);
65 ++testConfig.count;
66 }); 41 });
67 42
68 _defer(() => func()); 43 test('single arg to Future.catchError', () {
69 }); 44 var func = expectAsync((error) {
45 expect(error, isStateError);
46 ++count;
47 });
70 48
71 test('one of two optional positional args', () { 49 new Future(() {
72 var func = expectAsync(([arg0 = true, arg1 = true]) { 50 throw new StateError('test');
73 expect(arg0, isFalse); 51 }).catchError(func);
74 expect(arg1, isTrue);
75 ++testConfig.count;
76 }); 52 });
77 53
78 _defer(() => func(false)); 54 test('2 args to Future.catchError', () {
79 }); 55 var func = expectAsync((error, stack) {
56 expect(error, isStateError);
57 expect(stack is StackTrace, isTrue);
58 ++count;
59 });
80 60
81 test('two of two optional positional args', () { 61 new Future(() {
82 var func = expectAsync(([arg0 = true, arg1 = true]) { 62 throw new StateError('test');
83 expect(arg0, isFalse); 63 }).catchError(func);
84 expect(arg1, isNull);
85 ++testConfig.count;
86 }); 64 });
87 65
88 _defer(() => func(false, null)); 66 test('zero of two optional positional args', () {
67 var func = expectAsync(([arg0 = true, arg1 = true]) {
68 expect(arg0, isTrue);
69 expect(arg1, isTrue);
70 ++count;
71 });
72
73 new Future.sync(() => func());
74 });
75
76 test('one of two optional positional args', () {
77 var func = expectAsync(([arg0 = true, arg1 = true]) {
78 expect(arg0, isFalse);
79 expect(arg1, isTrue);
80 ++count;
81 });
82
83 new Future.sync(() => func(false));
84 });
85
86 test('two of two optional positional args', () {
87 var func = expectAsync(([arg0 = true, arg1 = true]) {
88 expect(arg0, isFalse);
89 expect(arg1, isNull);
90 ++count;
91 });
92
93 new Future.sync(() => func(false, null));
94 });
95
96 test('verify count', () {
97 expect(count, 8);
98 });
89 }); 99 });
90 }; 100 }
91
92 final expected = '8:0:0:8:8:::null:expectAsync zero params:'
93 ':expectAsync 1 param::expectAsync 2 param:'
94 ':single arg to Future.catchError::2 args to Future.catchError:'
95 ':zero of two optional positional args:'
96 ':one of two optional positional args:'
97 ':two of two optional positional args:';
OLDNEW
« no previous file with comments | « pkg/unittest/test/expect_async_args_test.dart ('k') | pkg/unittest/test/group_name_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698