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

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: CR feedback 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.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 import 'utils.dart';
13 13
14 var testFunction = (TestConfiguration testConfig) { 14 void main() => initTests(_test);
15 test('expectAsync zero params', () {
16 _defer(expectAsync(() {
17 ++testConfig.count;
18 }));
19 });
20 15
21 test('expectAsync 1 param', () { 16 void _test(message) {
22 var func = expectAsync((arg) { 17 initMetatest(message);
23 expect(arg, 0);
24 ++testConfig.count;
25 });
26 _defer(() => func(0));
27 });
28 18
29 test('expectAsync 2 param', () { 19 var count = 0;
30 var func = expectAsync((arg0, arg1) {
31 expect(arg0, 0);
32 expect(arg1, 1);
33 ++testConfig.count;
34 });
35 _defer(() => func(0, 1));
36 });
37 20
38 test('single arg to Future.catchError', () { 21 expectTestResults('expect async test', () {
39 var func = expectAsync((error) { 22 test('expectAsync zero params', () {
40 expect(error, isStateError); 23 defer(expectAsync(() {
41 ++testConfig.count; 24 ++count;
25 }));
42 }); 26 });
43 27
44 new Future(() { 28 test('expectAsync 1 param', () {
45 throw new StateError('test'); 29 var func = expectAsync((arg) {
46 }).catchError(func); 30 expect(arg, 0);
47 }); 31 ++count;
48 32 });
49 test('2 args to Future.catchError', () { 33 defer(() => func(0));
50 var func = expectAsync((error, stack) {
51 expect(error, isStateError);
52 expect(stack is StackTrace, isTrue);
53 ++testConfig.count;
54 }); 34 });
55 35
56 new Future(() { 36 test('expectAsync 2 param', () {
57 throw new StateError('test'); 37 var func = expectAsync((arg0, arg1) {
58 }).catchError(func); 38 expect(arg0, 0);
59 }); 39 expect(arg1, 1);
60 40 ++count;
61 test('zero of two optional positional args', () { 41 });
62 var func = expectAsync(([arg0 = true, arg1 = true]) { 42 defer(() => func(0, 1));
63 expect(arg0, isTrue);
64 expect(arg1, isTrue);
65 ++testConfig.count;
66 }); 43 });
67 44
68 _defer(() => func()); 45 test('single arg to Future.catchError', () {
69 }); 46 var func = expectAsync((error) {
47 expect(error, isStateError);
48 ++count;
49 });
70 50
71 test('one of two optional positional args', () { 51 new Future(() {
72 var func = expectAsync(([arg0 = true, arg1 = true]) { 52 throw new StateError('test');
73 expect(arg0, isFalse); 53 }).catchError(func);
74 expect(arg1, isTrue);
75 ++testConfig.count;
76 }); 54 });
77 55
78 _defer(() => func(false)); 56 test('2 args to Future.catchError', () {
79 }); 57 var func = expectAsync((error, stack) {
58 expect(error, isStateError);
59 expect(stack is StackTrace, isTrue);
60 ++count;
61 });
80 62
81 test('two of two optional positional args', () { 63 new Future(() {
82 var func = expectAsync(([arg0 = true, arg1 = true]) { 64 throw new StateError('test');
83 expect(arg0, isFalse); 65 }).catchError(func);
84 expect(arg1, isNull);
85 ++testConfig.count;
86 }); 66 });
87 67
88 _defer(() => func(false, null)); 68 test('zero of two optional positional args', () {
89 }); 69 var func = expectAsync(([arg0 = true, arg1 = true]) {
90 }; 70 expect(arg0, isTrue);
71 expect(arg1, isTrue);
72 ++count;
73 });
91 74
92 final expected = '8:0:0:8:8:::null:expectAsync zero params:' 75 defer(() => func());
93 ':expectAsync 1 param::expectAsync 2 param:' 76 });
94 ':single arg to Future.catchError::2 args to Future.catchError:' 77
95 ':zero of two optional positional args:' 78 test('one of two optional positional args', () {
96 ':one of two optional positional args:' 79 var func = expectAsync(([arg0 = true, arg1 = true]) {
97 ':two of two optional positional args:'; 80 expect(arg0, isFalse);
81 expect(arg1, isTrue);
82 ++count;
83 });
84
85 defer(() => func(false));
86 });
87
88 test('two of two optional positional args', () {
89 var func = expectAsync(([arg0 = true, arg1 = true]) {
90 expect(arg0, isFalse);
91 expect(arg1, isNull);
92 ++count;
93 });
94
95 defer(() => func(false, null));
96 });
97
98 test('verify count', () {
99 expect(count, 8);
100 });
101 }, new List.filled(9, {'result': 'pass' }));
102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698