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

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

Issue 12218127: Revert unittest test that makes use of function names as dart2js does not support this. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | « no previous file | 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 _result = buildStatusString(passed, failed, errors, results, 71 _result = buildStatusString(passed, failed, errors, results,
72 count: count, setup: setup, teardown: teardown, 72 count: count, setup: setup, teardown: teardown,
73 uncaughtError: uncaughtError); 73 uncaughtError: uncaughtError);
74 } 74 }
75 75
76 void onDone(bool success) { 76 void onDone(bool success) {
77 _port.send(_result); 77 _port.send(_result);
78 } 78 }
79 } 79 }
80 80
81 foo() {
82 ++_testconfig.count;
83 }
84
85 runTest() { 81 runTest() {
86 port.receive((testName, sendport) { 82 port.receive((testName, sendport) {
87 configure(_testconfig = new TestConfiguration(sendport)); 83 configure(_testconfig = new TestConfiguration(sendport));
88 if (testName == 'single correct test') { 84 if (testName == 'single correct test') {
89 test(testName, () => expect(2 + 3, equals(5))); 85 test(testName, () => expect(2 + 3, equals(5)));
90 } else if (testName == 'single failing test') { 86 } else if (testName == 'single failing test') {
91 test(testName, () => expect(2 + 2, equals(5))); 87 test(testName, () => expect(2 + 2, equals(5)));
92 } else if (testName == 'exception test') { 88 } else if (testName == 'exception test') {
93 test(testName, () { throw new Exception('Fail.'); }); 89 test(testName, () { throw new Exception('Fail.'); });
94 } else if (testName == 'group name test') { 90 } else if (testName == 'group name test') {
(...skipping 15 matching lines...) Expand all
110 }); 106 });
111 } else if (testName == 'setup and teardown test') { 107 } else if (testName == 'setup and teardown test') {
112 group('a', () { 108 group('a', () {
113 setUp(() { _testconfig.setup = 'setup'; }); 109 setUp(() { _testconfig.setup = 'setup'; });
114 tearDown(() { _testconfig.teardown = 'teardown'; }); 110 tearDown(() { _testconfig.teardown = 'teardown'; });
115 test(testName, () {}); 111 test(testName, () {});
116 }); 112 });
117 } else if (testName == 'correct callback test') { 113 } else if (testName == 'correct callback test') {
118 test(testName, 114 test(testName,
119 () =>_defer(expectAsync0((){ ++_testconfig.count;}))); 115 () =>_defer(expectAsync0((){ ++_testconfig.count;})));
120 } else if (testName == 'excess callback test with callback name') { 116 } else if (testName == 'excess callback test') {
121 test(testName, () { 117 test(testName, () {
122 var _callback = expectAsync0(foo); 118 var _callback = expectAsync0(() => ++_testconfig.count);
123 _defer(_callback); 119 _defer(_callback);
124 _defer(_callback); 120 _defer(_callback);
125 }); 121 });
126 } else if (testName == 'completion test') { 122 } else if (testName == 'completion test') {
127 test(testName, () { 123 test(testName, () {
128 var _callback; 124 var _callback;
129 _callback = expectAsyncUntil0(() { 125 _callback = expectAsyncUntil0(() {
130 if (++_testconfig.count < 10) { 126 if (++_testconfig.count < 10) {
131 _defer(_callback); 127 _defer(_callback);
132 } 128 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 main() { 255 main() {
260 tests = [ 256 tests = [
261 'single correct test', 257 'single correct test',
262 'single failing test', 258 'single failing test',
263 'exception test', 259 'exception test',
264 'group name test', 260 'group name test',
265 'setup test', 261 'setup test',
266 'teardown test', 262 'teardown test',
267 'setup and teardown test', 263 'setup and teardown test',
268 'correct callback test', 264 'correct callback test',
269 'excess callback test with callback name', 265 'excess callback test',
270 'completion test', 266 'completion test',
271 'async exception test', 267 'async exception test',
272 'late exception test', 268 'late exception test',
273 'middle exception test', 269 'middle exception test',
274 'async setup/teardown test' 270 'async setup/teardown test'
275 ]; 271 ];
276 272
277 expected = [ 273 expected = [
278 buildStatusString(1, 0, 0, tests[0]), 274 buildStatusString(1, 0, 0, tests[0]),
279 buildStatusString(0, 1, 0, tests[1], 275 buildStatusString(0, 1, 0, tests[1],
280 message: 'Expected: <5> but: was <4>.'), 276 message: 'Expected: <5> but: was <4>.'),
281 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), 277 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'),
282 buildStatusString(2, 0, 0, 'a a::a b b'), 278 buildStatusString(2, 0, 0, 'a a::a b b'),
283 buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'), 279 buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'),
284 buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '', 280 buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '',
285 teardown: 'teardown'), 281 teardown: 'teardown'),
286 buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0, 282 buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0,
287 setup: 'setup', teardown: 'teardown'), 283 setup: 'setup', teardown: 'teardown'),
288 buildStatusString(1, 0, 0, tests[7], count: 1), 284 buildStatusString(1, 0, 0, tests[7], count: 1),
289 buildStatusString(0, 0, 1, tests[8], count: 1, 285 buildStatusString(0, 0, 1, tests[8], count: 1,
290 message: 'Callback foo called more times than expected (2 > 1).'), 286 message: 'Callback called more times than expected (2 > 1).'),
291 buildStatusString(1, 0, 0, tests[9], count: 10), 287 buildStatusString(1, 0, 0, tests[9], count: 10),
292 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), 288 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'),
293 buildStatusString(1, 0, 1, 'testOne', 289 buildStatusString(1, 0, 1, 'testOne',
294 message: 'Callback called after already being marked as done ' 290 message: 'Callback called after already being marked as done '
295 '(1).:testTwo:'), 291 '(1).:testTwo:'),
296 buildStatusString(2, 1, 0, 292 buildStatusString(2, 1, 0,
297 'testOne::testTwo:Expected: false but: was <true>.:testThree'), 293 'testOne::testTwo:Expected: false but: was <true>.:testThree'),
298 buildStatusString(2, 0, 3, 294 buildStatusString(2, 0, 3,
299 'good setup/good teardown foo1::' 295 'good setup/good teardown foo1::'
300 'good setup/bad teardown foo2:good setup/bad teardown ' 296 'good setup/bad teardown foo2:good setup/bad teardown '
301 'foo2: Test teardown failed: Failed to complete tearDown:' 297 'foo2: Test teardown failed: Failed to complete tearDown:'
302 'bad setup/good teardown foo3:bad setup/good teardown ' 298 'bad setup/good teardown foo3:bad setup/good teardown '
303 'foo3: Test setup failed: Failed to complete setUp:' 299 'foo3: Test setup failed: Failed to complete setUp:'
304 'bad setup/bad teardown foo4:bad setup/bad teardown ' 300 'bad setup/bad teardown foo4:bad setup/bad teardown '
305 'foo4: Test teardown failed: Failed to complete tearDown:' 301 'foo4: Test teardown failed: Failed to complete tearDown:'
306 'post groups') 302 'post groups')
307 ]; 303 ];
308 304
309 actual = []; 305 actual = [];
310 306
311 nextTest(0); 307 nextTest(0);
312 } 308 }
313 309
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698