4
4
5
5
import 'dart:io' ;
6
6
7
- import 'package:test/test .dart' ;
7
+ import 'package:test_api/test_api .dart' ;
8
8
9
9
import 'internal.dart' ;
10
10
11
11
/// Matcher that successfully matches against any instance of [Directory] .
12
- const Matcher isDirectory = const isInstanceOf <Directory >();
12
+ const Matcher isDirectory = TypeMatcher <Directory >();
13
13
14
14
/// Matcher that successfully matches against any instance of [File] .
15
- const Matcher isFile = const isInstanceOf <File >();
15
+ const Matcher isFile = TypeMatcher <File >();
16
16
17
17
/// Matcher that successfully matches against any instance of [Link] .
18
- const Matcher isLink = const isInstanceOf <Link >();
18
+ const Matcher isLink = TypeMatcher <Link >();
19
19
20
20
/// Matcher that successfully matches against any instance of
21
21
/// [FileSystemEntity] .
22
- const Matcher isFileSystemEntity = const isInstanceOf <FileSystemEntity >();
22
+ const Matcher isFileSystemEntity = TypeMatcher <FileSystemEntity >();
23
23
24
24
/// Matcher that successfully matches against any instance of [FileStat] .
25
- const Matcher isFileStat = const isInstanceOf <FileStat >();
25
+ const Matcher isFileStat = TypeMatcher <FileStat >();
26
26
27
27
/// Returns a [Matcher] that matches [path] against an entity's path.
28
28
///
29
29
/// [path] may be a String, a predicate function, or a [Matcher] . If it is
30
30
/// a String, it will be wrapped in an equality matcher.
31
- Matcher hasPath (dynamic path) => new _HasPath (path);
31
+ Matcher hasPath (dynamic path) => _HasPath (path);
32
32
33
33
/// Returns a [Matcher] that successfully matches against an instance of
34
34
/// [FileSystemException] .
@@ -39,7 +39,7 @@ Matcher hasPath(dynamic path) => new _HasPath(path);
39
39
/// [osErrorCode] may be an `int` , a predicate function, or a [Matcher] . If it
40
40
/// is an `int` , it will be wrapped in an equality matcher.
41
41
Matcher isFileSystemException ([dynamic osErrorCode]) =>
42
- new _FileSystemException (osErrorCode);
42
+ _FileSystemException (osErrorCode);
43
43
44
44
/// Returns a matcher that successfully matches against a future or function
45
45
/// that throws a [FileSystemException] .
@@ -67,14 +67,14 @@ void expectFileSystemException(dynamic osErrorCode, void callback()) {
67
67
68
68
/// Matcher that successfully matches against a [FileSystemEntity] that
69
69
/// exists ([FileSystemEntity.existsSync] returns true).
70
- const Matcher exists = const _Exists ();
70
+ const Matcher exists = _Exists ();
71
71
72
72
class _FileSystemException extends Matcher {
73
- final Matcher _matcher;
74
-
75
73
_FileSystemException (dynamic osErrorCode)
76
74
: _matcher = _wrapMatcher (osErrorCode);
77
75
76
+ final Matcher _matcher;
77
+
78
78
static Matcher _wrapMatcher (dynamic osErrorCode) {
79
79
if (osErrorCode == null ) {
80
80
return null ;
@@ -85,8 +85,8 @@ class _FileSystemException extends Matcher {
85
85
@override
86
86
bool matches (dynamic item, Map <dynamic , dynamic > matchState) {
87
87
if (item is FileSystemException ) {
88
- return ( _matcher == null ||
89
- _matcher.matches (item.osError? .errorCode, matchState)) ;
88
+ return _matcher == null ||
89
+ _matcher.matches (item.osError? .errorCode, matchState);
90
90
}
91
91
return false ;
92
92
}
@@ -103,10 +103,10 @@ class _FileSystemException extends Matcher {
103
103
}
104
104
105
105
class _HasPath extends Matcher {
106
- final Matcher _matcher;
107
-
108
106
_HasPath (dynamic path) : _matcher = wrapMatcher (path);
109
107
108
+ final Matcher _matcher;
109
+
110
110
@override
111
111
bool matches (dynamic item, Map <dynamic , dynamic > matchState) =>
112
112
_matcher.matches (item.path, matchState);
@@ -125,7 +125,7 @@ class _HasPath extends Matcher {
125
125
bool verbose,
126
126
) {
127
127
desc.add ('has path: \' ${item .path }\' ' ).add ('\n Which: ' );
128
- Description pathDesc = new StringDescription ();
128
+ final Description pathDesc = StringDescription ();
129
129
_matcher.describeMismatch (item.path, pathDesc, matchState, verbose);
130
130
desc.add (pathDesc.toString ());
131
131
return desc;
0 commit comments