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

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

Issue 14212003: TBR: Revrt r21819 until I can figure out why ity is breaking the scheduled_test package. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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/lib/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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 _result = buildStatusString(passed, failed, errors, results, 61 _result = buildStatusString(passed, failed, errors, results,
62 count: count, setup: setup, teardown: teardown, 62 count: count, setup: setup, teardown: teardown,
63 uncaughtError: uncaughtError); 63 uncaughtError: uncaughtError);
64 } 64 }
65 65
66 void onDone(bool success) { 66 void onDone(bool success) {
67 _port.send(_result); 67 _port.send(_result);
68 } 68 }
69 } 69 }
70 70
71 makeDelayedSetup(index, s) => () {
72 return new Future.delayed(new Duration(milliseconds:1), () {
73 s.write('l$index U ');
74 });
75 };
76
77 makeDelayedTeardown(index, s) => () {
78 return new Future.delayed(new Duration(milliseconds:1), () {
79 s.write('l$index D ');
80 });
81 };
82
83 makeImmediateSetup(index, s) => () {
84 s.write('l$index U ');
85 };
86
87 makeImmediateTeardown(index, s) => () {
88 s.write('l$index D ');
89 };
90
91 runTest() { 71 runTest() {
92 port.receive((String testName, sendport) { 72 port.receive((String testName, sendport) {
93 var testConfig = new TestConfiguration(sendport); 73 var testConfig = new TestConfiguration(sendport);
94 unittestConfiguration = testConfig; 74 unittestConfiguration = testConfig;
95 75
96 if (testName == 'single correct test') { 76 if (testName == 'single correct test') {
97 test(testName, () => expect(2 + 3, equals(5))); 77 test(testName, () => expect(2 + 3, equals(5)));
98 } else if (testName == 'single failing test') { 78 } else if (testName == 'single failing test') {
99 test(testName, () => expect(2 + 2, equals(5))); 79 test(testName, () => expect(2 + 2, equals(5)));
100 } else if (testName == 'exception test') { 80 } else if (testName == 'exception test') {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 }); 292 });
313 test('foo6', () { 293 test('foo6', () {
314 }); 294 });
315 } else if (testName == 'testCases immutable') { 295 } else if (testName == 'testCases immutable') {
316 test(testName, () { 296 test(testName, () {
317 expect(() => testCases.clear(), throwsUnsupportedError); 297 expect(() => testCases.clear(), throwsUnsupportedError);
318 expect(() => testCases.removeLast(), throwsUnsupportedError); 298 expect(() => testCases.removeLast(), throwsUnsupportedError);
319 }); 299 });
320 } else if (testName == 'runTests without tests') { 300 } else if (testName == 'runTests without tests') {
321 runTests(); 301 runTests();
322 } else if (testName == 'nested groups setup/teardown') {
323 StringBuffer s = new StringBuffer();
324 group('level 1', () {
325 setUp(makeDelayedSetup(1, s));
326 group('level 2', () {
327 setUp(makeImmediateSetup(2, s));
328 tearDown(makeDelayedTeardown(2, s));
329 group('level 3', () {
330 group('level 4', () {
331 setUp(makeDelayedSetup(4, s));
332 tearDown(makeImmediateTeardown(4, s));
333 group('level 5', () {
334 setUp(makeImmediateSetup(5, s));
335 group('level 6', () {
336 tearDown(makeDelayedTeardown(6, s));
337 test('inner', () {});
338 });
339 });
340 });
341 });
342 });
343 });
344 test('after nest', () {
345 expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D ");
346 });
347 } 302 }
348 }); 303 });
349 } 304 }
350 305
351 main() { 306 main() {
352 var tests = { 307 var tests = {
353 'single correct test': buildStatusString(1, 0, 0, 'single correct test'), 308 'single correct test': buildStatusString(1, 0, 0, 'single correct test'),
354 'single failing test': buildStatusString(0, 1, 0, 'single failing test', 309 'single failing test': buildStatusString(0, 1, 0, 'single failing test',
355 message: 'Expected: <5> but: was <4>.'), 310 message: 'Expected: <5> but: was <4>.'),
356 'exception test': buildStatusString(0, 1, 0, 'exception test', 311 'exception test': buildStatusString(0, 1, 0, 'exception test',
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 'foo5'), 348 'foo5'),
394 'test returning future using Timer': buildStatusString(2, 4, 0, 349 'test returning future using Timer': buildStatusString(2, 4, 0,
395 'successful::' 350 'successful::'
396 'fail1:Expected: <false> but: was <true>.:' 351 'fail1:Expected: <false> but: was <true>.:'
397 'error1:Callback called more times than expected (1).:' 352 'error1:Callback called more times than expected (1).:'
398 'fail2:failure:' 353 'fail2:failure:'
399 'error2:Callback called more times than expected (1).:' 354 'error2:Callback called more times than expected (1).:'
400 'foo6'), 355 'foo6'),
401 'testCases immutable': 356 'testCases immutable':
402 buildStatusString(1, 0, 0, 'testCases immutable'), 357 buildStatusString(1, 0, 0, 'testCases immutable'),
403 'runTests without tests': buildStatusString(0, 0, 0, null), 358 'runTests without tests': buildStatusString(0, 0, 0, null)
404 'nested groups setup/teardown':
405 buildStatusString(2, 0, 0,
406 'level 1 level 2 level 3 level 4 level 5 level 6 inner::after nest')
407 }; 359 };
408 360
409 tests.forEach((String name, String expected) { 361 tests.forEach((String name, String expected) {
410 test(name, () => spawnFunction(runTest) 362 test(name, () => spawnFunction(runTest)
411 .call(name) 363 .call(name)
412 .then((String msg) => expect(msg.trim(), equals(expected)))); 364 .then((String msg) => expect(msg.trim(), equals(expected))));
413 }); 365 });
414 } 366 }
415 367
OLDNEW
« no previous file with comments | « pkg/unittest/lib/unittest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698