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 /** | 5 /** |
6 * A library for writing dart unit tests. | 6 * A library for writing dart unit tests. |
7 * | 7 * |
8 * To import this library, install the | 8 * To import this library, install the |
9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub | 9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub |
10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc) | 10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc) |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 void filterTests(testFilter) { | 682 void filterTests(testFilter) { |
683 var filterFunction; | 683 var filterFunction; |
684 if (testFilter is String) { | 684 if (testFilter is String) { |
685 RegExp re = new RegExp(testFilter); | 685 RegExp re = new RegExp(testFilter); |
686 filterFunction = (t) => re.hasMatch(t.description); | 686 filterFunction = (t) => re.hasMatch(t.description); |
687 } else if (testFilter is RegExp) { | 687 } else if (testFilter is RegExp) { |
688 filterFunction = (t) => testFilter.hasMatch(t.description); | 688 filterFunction = (t) => testFilter.hasMatch(t.description); |
689 } else if (testFilter is Function) { | 689 } else if (testFilter is Function) { |
690 filterFunction = testFilter; | 690 filterFunction = testFilter; |
691 } | 691 } |
692 _tests.retainMatching(filterFunction); | 692 _tests.retainWhere(filterFunction); |
693 } | 693 } |
694 | 694 |
695 /** Runs all queued tests, one at a time. */ | 695 /** Runs all queued tests, one at a time. */ |
696 void runTests() { | 696 void runTests() { |
697 _currentTest = 0; | 697 _currentTest = 0; |
698 _currentGroup = ''; | 698 _currentGroup = ''; |
699 | 699 |
700 // If we are soloing a test, remove all the others. | 700 // If we are soloing a test, remove all the others. |
701 if (_soloTest != null) { | 701 if (_soloTest != null) { |
702 filterTests((t) => t == _soloTest); | 702 filterTests((t) => t == _soloTest); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 } | 851 } |
852 | 852 |
853 /** Enable a test by ID. */ | 853 /** Enable a test by ID. */ |
854 void enableTest(int testId) => _setTestEnabledState(testId, true); | 854 void enableTest(int testId) => _setTestEnabledState(testId, true); |
855 | 855 |
856 /** Disable a test by ID. */ | 856 /** Disable a test by ID. */ |
857 void disableTest(int testId) => _setTestEnabledState(testId, false); | 857 void disableTest(int testId) => _setTestEnabledState(testId, false); |
858 | 858 |
859 /** Signature for a test function. */ | 859 /** Signature for a test function. */ |
860 typedef dynamic TestFunction(); | 860 typedef dynamic TestFunction(); |
OLD | NEW |