| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * A library for writing dart unit tests. | 6 * A library for writing dart unit tests. |
| 7 * | 7 * |
| 8 * To import this library, use the pub package manager. | 8 * To import this library, use the pub package manager. |
| 9 * Create a pubspec.yaml file in your project and add | 9 * Create a pubspec.yaml file in your project and add |
| 10 * a dependency on unittest with the following lines: | 10 * a dependency on unittest with the following lines: |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 void filterTests(testFilter) { | 730 void filterTests(testFilter) { |
| 731 var filterFunction; | 731 var filterFunction; |
| 732 if (testFilter is String) { | 732 if (testFilter is String) { |
| 733 RegExp re = new RegExp(testFilter); | 733 RegExp re = new RegExp(testFilter); |
| 734 filterFunction = (t) => re.hasMatch(t.description); | 734 filterFunction = (t) => re.hasMatch(t.description); |
| 735 } else if (testFilter is RegExp) { | 735 } else if (testFilter is RegExp) { |
| 736 filterFunction = (t) => testFilter.hasMatch(t.description); | 736 filterFunction = (t) => testFilter.hasMatch(t.description); |
| 737 } else if (testFilter is Function) { | 737 } else if (testFilter is Function) { |
| 738 filterFunction = testFilter; | 738 filterFunction = testFilter; |
| 739 } | 739 } |
| 740 _tests = _tests.where(filterFunction); | 740 _tests = _tests.where(filterFunction).toList(); |
| 741 } | 741 } |
| 742 | 742 |
| 743 /** Runs all queued tests, one at a time. */ | 743 /** Runs all queued tests, one at a time. */ |
| 744 runTests() { | 744 runTests() { |
| 745 _currentTest = 0; | 745 _currentTest = 0; |
| 746 _currentGroup = ''; | 746 _currentGroup = ''; |
| 747 | 747 |
| 748 // If we are soloing a test, remove all the others. | 748 // If we are soloing a test, remove all the others. |
| 749 if (_soloTest != null) { | 749 if (_soloTest != null) { |
| 750 filterTests((t) => t == _soloTest); | 750 filterTests((t) => t == _soloTest); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 } | 900 } |
| 901 | 901 |
| 902 /** Enable a test by ID. */ | 902 /** Enable a test by ID. */ |
| 903 void enableTest(int testId) => _setTestEnabledState(testId, true); | 903 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 904 | 904 |
| 905 /** Disable a test by ID. */ | 905 /** Disable a test by ID. */ |
| 906 void disableTest(int testId) => _setTestEnabledState(testId, false); | 906 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 907 | 907 |
| 908 /** Signature for a test function. */ | 908 /** Signature for a test function. */ |
| 909 typedef void TestFunction(); | 909 typedef void TestFunction(); |
| OLD | NEW |