| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library unittest; | 5 library unittest; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:isolate'; | |
| 10 | 9 |
| 11 import 'package:matcher/matcher.dart' | 10 import 'src/configuration.dart'; |
| 12 show | 11 import 'src/expect.dart'; |
| 13 DefaultFailureHandler, | |
| 14 configureExpectFailureHandler, | |
| 15 TestFailure, | |
| 16 wrapAsync; | |
| 17 export 'package:matcher/matcher.dart'; | |
| 18 | |
| 19 import 'src/utils.dart'; | 12 import 'src/utils.dart'; |
| 20 | 13 |
| 21 import 'src/configuration.dart'; | 14 export 'package:matcher/matcher.dart' |
| 15 hide |
| 16 completes, |
| 17 completion, |
| 18 configureExpectFailureHandler, |
| 19 DefaultFailureHandler, |
| 20 ErrorFormatter, |
| 21 expect, |
| 22 fail, |
| 23 FailureHandler, |
| 24 getOrCreateExpectFailureHandler, |
| 25 prints, |
| 26 TestFailure, |
| 27 Throws, |
| 28 throws, |
| 29 throwsA, |
| 30 throwsArgumentError, |
| 31 throwsConcurrentModificationError, |
| 32 throwsCyclicInitializationError, |
| 33 throwsException, |
| 34 throwsFormatException, |
| 35 throwsNoSuchMethodError, |
| 36 throwsNullThrownError, |
| 37 throwsRangeError, |
| 38 throwsStateError, |
| 39 throwsUnimplementedError, |
| 40 throwsUnsupportedError; |
| 41 |
| 22 export 'src/configuration.dart'; | 42 export 'src/configuration.dart'; |
| 43 export 'src/expect.dart'; |
| 44 export 'src/simple_configuration.dart'; |
| 45 export 'src/future_matchers.dart'; |
| 46 export 'src/prints_matcher.dart'; |
| 47 export 'src/throws_matcher.dart'; |
| 48 export 'src/throws_matchers.dart'; |
| 23 | 49 |
| 24 part 'src/simple_configuration.dart'; | |
| 25 part 'src/group_context.dart'; | 50 part 'src/group_context.dart'; |
| 26 part 'src/spread_args_helper.dart'; | 51 part 'src/spread_args_helper.dart'; |
| 27 part 'src/test_case.dart'; | 52 part 'src/test_case.dart'; |
| 28 part 'src/test_environment.dart'; | 53 part 'src/test_environment.dart'; |
| 29 | 54 |
| 30 const Symbol _UNITTEST_ENVIRONMENT = #unittest.environment; | 55 const Symbol _UNITTEST_ENVIRONMENT = #unittest.environment; |
| 31 | 56 |
| 32 final _TestEnvironment _defaultEnvironment = new _TestEnvironment(); | 57 final _TestEnvironment _defaultEnvironment = new _TestEnvironment(); |
| 33 | 58 |
| 34 /** | 59 /** |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 /// Lazily initializes the test library if not already initialized. | 428 /// Lazily initializes the test library if not already initialized. |
| 404 void ensureInitialized() { | 429 void ensureInitialized() { |
| 405 _ensureInitialized(true); | 430 _ensureInitialized(true); |
| 406 } | 431 } |
| 407 | 432 |
| 408 void _ensureInitialized(bool configAutoStart) { | 433 void _ensureInitialized(bool configAutoStart) { |
| 409 if (_environment.initialized) { | 434 if (_environment.initialized) { |
| 410 return; | 435 return; |
| 411 } | 436 } |
| 412 _environment.initialized = true; | 437 _environment.initialized = true; |
| 413 // Hook our async guard into the matcher library. | |
| 414 wrapAsync = (f, [id]) => expectAsync(f, id: id); | |
| 415 | 438 |
| 416 _environment.uncaughtErrorMessage = null; | 439 _environment.uncaughtErrorMessage = null; |
| 417 | 440 |
| 418 unittestConfiguration.onInit(); | 441 unittestConfiguration.onInit(); |
| 419 | 442 |
| 420 if (configAutoStart && _config.autoStart) { | 443 if (configAutoStart && _config.autoStart) { |
| 421 // Immediately queue the suite up. It will run after a timeout (i.e. after | 444 // Immediately queue the suite up. It will run after a timeout (i.e. after |
| 422 // main() has returned). | 445 // main() has returned). |
| 423 scheduleMicrotask(runTests); | 446 scheduleMicrotask(runTests); |
| 424 } | 447 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 /// | 496 /// |
| 474 /// This allows for multiple invocations of the unittest library in the same | 497 /// This allows for multiple invocations of the unittest library in the same |
| 475 /// application instance. | 498 /// application instance. |
| 476 /// This is useful when, for example, creating a test runner application which | 499 /// This is useful when, for example, creating a test runner application which |
| 477 /// needs to create a new pristine test environment on each invocation to run | 500 /// needs to create a new pristine test environment on each invocation to run |
| 478 /// a given set of test. | 501 /// a given set of test. |
| 479 dynamic withTestEnvironment(callback()) { | 502 dynamic withTestEnvironment(callback()) { |
| 480 return runZoned(callback, | 503 return runZoned(callback, |
| 481 zoneValues: {_UNITTEST_ENVIRONMENT: new _TestEnvironment()}); | 504 zoneValues: {_UNITTEST_ENVIRONMENT: new _TestEnvironment()}); |
| 482 } | 505 } |
| OLD | NEW |