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

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

Issue 10946038: Fixed a nasty bug in unittest, where is we have a non-async test that throws an exception, followed… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « no previous file | pkg/unittest/unittest.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) 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 test('testOne', () { 132 test('testOne', () {
133 var f = expectAsync0(() {}); 133 var f = expectAsync0(() {});
134 _defer(protectAsync0(() { 134 _defer(protectAsync0(() {
135 _defer(protectAsync0(() => expect(false))); 135 _defer(protectAsync0(() => expect(false)));
136 expect(false); 136 expect(false);
137 })); 137 }));
138 }); 138 });
139 test('testTwo', () { 139 test('testTwo', () {
140 _defer(expectAsync0(() {})); 140 _defer(expectAsync0(() {}));
141 }); 141 });
142 } else if (testName == 'middle exception test') {
143 test('testOne', () { expect(true, isTrue); });
144 test('testTwo', () { expect(true, isFalse); });
145 test('testThree', () {
146 var done = expectAsync0((){});
147 _defer(() {
148 expect(true, isTrue);
149 done();
150 });
151 });
142 } 152 }
143 }); 153 });
144 } 154 }
145 155
146 void nextTest(int testNum) { 156 void nextTest(int testNum) {
147 SendPort sport = spawnFunction(runTest); 157 SendPort sport = spawnFunction(runTest);
148 sport.call(tests[testNum]).then((msg) { 158 sport.call(tests[testNum]).then((msg) {
149 actual.add(msg); 159 actual.add(msg);
150 if (actual.length == expected.length) { 160 if (actual.length == expected.length) {
151 for (var i = 0; i < tests.length; i++) { 161 for (var i = 0; i < tests.length; i++) {
(...skipping 11 matching lines...) Expand all
163 'single failing test', 173 'single failing test',
164 'exception test', 174 'exception test',
165 'group name test', 175 'group name test',
166 'setup test', 176 'setup test',
167 'teardown test', 177 'teardown test',
168 'setup and teardown test', 178 'setup and teardown test',
169 'correct callback test', 179 'correct callback test',
170 'excess callback test', 180 'excess callback test',
171 'completion test', 181 'completion test',
172 'async exception test', 182 'async exception test',
173 'late exception test' 183 'late exception test',
184 'middle exception test'
174 ]; 185 ];
175 186
176 expected = [ 187 expected = [
177 buildStatusString(1, 0, 0, tests[0]), 188 buildStatusString(1, 0, 0, tests[0]),
178 buildStatusString(0, 1, 0, tests[1], 189 buildStatusString(0, 1, 0, tests[1],
179 message: 'Expected: <5> but: was <4>.'), 190 message: 'Expected: <5> but: was <4>.'),
180 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), 191 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'),
181 buildStatusString(2, 0, 0, 'a a::a b b'), 192 buildStatusString(2, 0, 0, 'a a::a b b'),
182 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'), 193 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'),
183 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'), 194 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'),
184 buildStatusString(1, 0, 0, 'a ${tests[6]}', 0, 195 buildStatusString(1, 0, 0, 'a ${tests[6]}', 0,
185 'setup', 'teardown'), 196 'setup', 'teardown'),
186 buildStatusString(1, 0, 0, tests[7], 1), 197 buildStatusString(1, 0, 0, tests[7], 1),
187 buildStatusString(0, 0, 1, tests[8], 1, 198 buildStatusString(0, 0, 1, tests[8], 1,
188 message: 'Callback called more times than expected (2 > 1).'), 199 message: 'Callback called more times than expected (2 > 1).'),
189 buildStatusString(1, 0, 0, tests[9], 10), 200 buildStatusString(1, 0, 0, tests[9], 10),
190 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), 201 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:') 202 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread y being marked as done (1).:testTwo:'),
203 buildStatusString(2, 1, 0, 'testOne::testTwo:Expected: false but: was <true> .:testThree')
192 ]; 204 ];
193 205
194 actual = []; 206 actual = [];
195 207
196 nextTest(0); 208 nextTest(0);
197 } 209 }
198 210
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698