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

Side by Side Diff: tests/lib/unittest/unittest_test.dart

Issue 10830128: Ability to guard callbacks that may never get called. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « lib/unittest/unittest.dart ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // TODO(gram): 5 // TODO(gram):
6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g.
7 // insufficient callbacks, because the timeout is controlled externally 7 // insufficient callbacks, because the timeout is controlled externally
8 // (test.dart?), and we would need to use a shorter timeout for the inner tests 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests
9 // so the outer timeout doesn't fire. So I removed all such tests. 9 // so the outer timeout doesn't fire. So I removed all such tests.
10 // I'd like to revisit this at some point. 10 // I'd like to revisit this at some point.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 }, 122 },
123 () => (_testconfig.count == 10)); 123 () => (_testconfig.count == 10));
124 _defer(_callback); 124 _defer(_callback);
125 }); 125 });
126 } else if (testName == 'async exception test') { 126 } else if (testName == 'async exception test') {
127 test(testName, () { 127 test(testName, () {
128 expectAsync0(() {}); 128 expectAsync0(() {});
129 _defer(() => guardAsync(() { throw "error!"; })); 129 _defer(() => guardAsync(() { throw "error!"; }));
130 }); 130 });
131 } else if (testName == 'late exception test') {
132 test('testOne', () {
133 var f = expectAsync0(() {});
134 _defer(protectAsync0(() {
135 _defer(protectAsync0(() => expect(false)));
136 expect(false);
137 }));
138 });
139 test('testTwo', () {
140 _defer(expectAsync0(() {}));
141 });
131 } 142 }
132 }); 143 });
133 } 144 }
134 145
135 void nextTest(int testNum) { 146 void nextTest(int testNum) {
136 SendPort sport = spawnFunction(runTest); 147 SendPort sport = spawnFunction(runTest);
137 sport.call(tests[testNum]).then((msg) { 148 sport.call(tests[testNum]).then((msg) {
138 actual.add(msg); 149 actual.add(msg);
139 if (actual.length == expected.length) { 150 if (actual.length == expected.length) {
140 for (var i = 0; i < tests.length; i++) { 151 for (var i = 0; i < tests.length; i++) {
(...skipping 10 matching lines...) Expand all
151 'single correct test', 162 'single correct test',
152 'single failing test', 163 'single failing test',
153 'exception test', 164 'exception test',
154 'group name test', 165 'group name test',
155 'setup test', 166 'setup test',
156 'teardown test', 167 'teardown test',
157 'setup and teardown test', 168 'setup and teardown test',
158 'correct callback test', 169 'correct callback test',
159 'excess callback test', 170 'excess callback test',
160 'completion test', 171 'completion test',
161 'async exception test' 172 'async exception test',
173 'late exception test'
162 ]; 174 ];
163 175
164 expected = [ 176 expected = [
165 buildStatusString(1, 0, 0, tests[0]), 177 buildStatusString(1, 0, 0, tests[0]),
166 buildStatusString(0, 1, 0, tests[1], 178 buildStatusString(0, 1, 0, tests[1],
167 message: 'Expected: <5> but: was <4>.'), 179 message: 'Expected: <5> but: was <4>.'),
168 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), 180 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'),
169 buildStatusString(2, 0, 0, 'a a::a b b'), 181 buildStatusString(2, 0, 0, 'a a::a b b'),
170 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'), 182 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'),
171 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'), 183 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'),
172 buildStatusString(1, 0, 0, 'a ${tests[6]}', 0, 184 buildStatusString(1, 0, 0, 'a ${tests[6]}', 0,
173 'setup', 'teardown'), 185 'setup', 'teardown'),
174 buildStatusString(1, 0, 0, tests[7], 1), 186 buildStatusString(1, 0, 0, tests[7], 1),
175 buildStatusString(0, 0, 1, tests[8], 1, 187 buildStatusString(0, 0, 1, tests[8], 1,
176 message: 'Callback called more times than expected (2 > 1).'), 188 message: 'Callback called more times than expected (2 > 1).'),
177 buildStatusString(1, 0, 0, tests[9], 10), 189 buildStatusString(1, 0, 0, tests[9], 10),
178 buildStatusString(0, 0, 1, tests[10], message: 'Caught error!'), 190 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'),
191 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread y being marked as done (1).:testTwo:')
Siggi Cherem (dart-lang) 2012/08/02 00:42:09 80 col!
179 ]; 192 ];
180 193
181 actual = []; 194 actual = [];
182 195
183 nextTest(0); 196 nextTest(0);
184 } 197 }
185 198
OLDNEW
« no previous file with comments | « lib/unittest/unittest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698