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

Side by Side Diff: test/vm_listener_test.dart

Issue 934413002: Replace the existing unittest APIs with the new runner infrastructure. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 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
« no previous file with comments | « test/utils.dart ('k') | test/with_test_environment_test.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 7
8 import 'package:unittest/src/declarer.dart';
9 import 'package:unittest/src/invoker.dart'; 8 import 'package:unittest/src/invoker.dart';
10 import 'package:unittest/src/isolate_test.dart'; 9 import 'package:unittest/src/isolate_test.dart';
11 import 'package:unittest/src/live_test.dart'; 10 import 'package:unittest/src/live_test.dart';
12 import 'package:unittest/src/remote_exception.dart'; 11 import 'package:unittest/src/remote_exception.dart';
13 import 'package:unittest/src/state.dart'; 12 import 'package:unittest/src/state.dart';
14 import 'package:unittest/src/suite.dart'; 13 import 'package:unittest/src/suite.dart';
15 import 'package:unittest/src/vm_listener.dart'; 14 import 'package:unittest/src/vm_listener.dart';
16 import 'package:unittest/unittest.dart'; 15 import 'package:unittest/unittest.dart';
17 16
18 import 'utils.dart'; 17 import 'utils.dart';
19 18
20 /// The current declarer.
21 Declarer get _declarer => Zone.current[#unittest.declarer];
22
23 /// An isolate that's been spun up for the current test. 19 /// An isolate that's been spun up for the current test.
24 /// 20 ///
25 /// This is tracked so that it can be killed once the test is done. 21 /// This is tracked so that it can be killed once the test is done.
26 Isolate _isolate; 22 Isolate _isolate;
27 23
28 /// A live test that's running for the current test. 24 /// A live test that's running for the current test.
29 /// 25 ///
30 /// This is tracked so that it can be closed once the test is done. 26 /// This is tracked so that it can be closed once the test is done.
31 LiveTest _liveTest; 27 LiveTest _liveTest;
32 28
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 void _nonFunction(SendPort sendPort) => 301 void _nonFunction(SendPort sendPort) =>
306 VmListener.start(sendPort, () => null); 302 VmListener.start(sendPort, () => null);
307 303
308 /// An isolate entrypoint that returns a function with the wrong arity. 304 /// An isolate entrypoint that returns a function with the wrong arity.
309 void _wrongArity(SendPort sendPort) => 305 void _wrongArity(SendPort sendPort) =>
310 VmListener.start(sendPort, () => (_) {}); 306 VmListener.start(sendPort, () => (_) {});
311 307
312 /// An isolate entrypoint that defines three tests that succeed. 308 /// An isolate entrypoint that defines three tests that succeed.
313 void _successfulTests(SendPort sendPort) { 309 void _successfulTests(SendPort sendPort) {
314 VmListener.start(sendPort, () => () { 310 VmListener.start(sendPort, () => () {
315 _declarer.test("successful 1", () {}); 311 test("successful 1", () {});
316 _declarer.test("successful 2", () {}); 312 test("successful 2", () {});
317 _declarer.test("successful 3", () {}); 313 test("successful 3", () {});
318 }); 314 });
319 } 315 }
320 316
321 /// An isolate entrypoint that defines a test that fails. 317 /// An isolate entrypoint that defines a test that fails.
322 void _failingTest(SendPort sendPort) { 318 void _failingTest(SendPort sendPort) {
323 VmListener.start(sendPort, () => () { 319 VmListener.start(sendPort, () => () {
324 _declarer.test("failure", () => throw new TestFailure('oh no')); 320 test("failure", () => throw new TestFailure('oh no'));
325 }); 321 });
326 } 322 }
327 323
328 /// An isolate entrypoint that defines a test that fails after succeeding. 324 /// An isolate entrypoint that defines a test that fails after succeeding.
329 void _failAfterSucceedTest(SendPort sendPort) { 325 void _failAfterSucceedTest(SendPort sendPort) {
330 VmListener.start(sendPort, () => () { 326 VmListener.start(sendPort, () => () {
331 _declarer.test("fail after succeed", () { 327 test("fail after succeed", () {
332 pumpEventQueue().then((_) { 328 pumpEventQueue().then((_) {
333 throw new TestFailure('oh no'); 329 throw new TestFailure('oh no');
334 }); 330 });
335 }); 331 });
336 }); 332 });
337 } 333 }
338 334
339 /// An isolate entrypoint that defines a test that fails multiple times. 335 /// An isolate entrypoint that defines a test that fails multiple times.
340 void _multiFailTest(SendPort sendPort) { 336 void _multiFailTest(SendPort sendPort) {
341 VmListener.start(sendPort, () => () { 337 VmListener.start(sendPort, () => () {
342 _declarer.test("multiple failures", () { 338 test("multiple failures", () {
343 Invoker.current.addOutstandingCallback(); 339 Invoker.current.addOutstandingCallback();
344 new Future(() => throw new TestFailure("one")); 340 new Future(() => throw new TestFailure("one"));
345 new Future(() => throw new TestFailure("two")); 341 new Future(() => throw new TestFailure("two"));
346 new Future(() => throw new TestFailure("three")); 342 new Future(() => throw new TestFailure("three"));
347 new Future(() => throw new TestFailure("four")); 343 new Future(() => throw new TestFailure("four"));
348 }); 344 });
349 }); 345 });
350 } 346 }
351 347
352 /// An isolate entrypoint that defines a test that errors. 348 /// An isolate entrypoint that defines a test that errors.
353 void _errorTest(SendPort sendPort) { 349 void _errorTest(SendPort sendPort) {
354 VmListener.start(sendPort, () => () { 350 VmListener.start(sendPort, () => () {
355 _declarer.test("error", () => throw 'oh no'); 351 test("error", () => throw 'oh no');
356 }); 352 });
357 } 353 }
358 354
359 /// An isolate entrypoint that defines a test that errors after succeeding. 355 /// An isolate entrypoint that defines a test that errors after succeeding.
360 void _errorAfterSucceedTest(SendPort sendPort) { 356 void _errorAfterSucceedTest(SendPort sendPort) {
361 VmListener.start(sendPort, () => () { 357 VmListener.start(sendPort, () => () {
362 _declarer.test("error after succeed", () { 358 test("error after succeed", () {
363 pumpEventQueue().then((_) => throw 'oh no'); 359 pumpEventQueue().then((_) => throw 'oh no');
364 }); 360 });
365 }); 361 });
366 } 362 }
367 363
368 /// An isolate entrypoint that defines a test that errors multiple times. 364 /// An isolate entrypoint that defines a test that errors multiple times.
369 void _multiErrorTest(SendPort sendPort) { 365 void _multiErrorTest(SendPort sendPort) {
370 VmListener.start(sendPort, () => () { 366 VmListener.start(sendPort, () => () {
371 _declarer.test("multiple errors", () { 367 test("multiple errors", () {
372 Invoker.current.addOutstandingCallback(); 368 Invoker.current.addOutstandingCallback();
373 new Future(() => throw "one"); 369 new Future(() => throw "one");
374 new Future(() => throw "two"); 370 new Future(() => throw "two");
375 new Future(() => throw "three"); 371 new Future(() => throw "three");
376 new Future(() => throw "four"); 372 new Future(() => throw "four");
377 }); 373 });
378 }); 374 });
379 } 375 }
OLDNEW
« no previous file with comments | « test/utils.dart ('k') | test/with_test_environment_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698