@@ -36,33 +36,33 @@ abstract class FileDescriptor extends Descriptor {
3636 /// To match a [Matcher] against a file's binary contents, use [new
3737 /// FileDescriptor.binaryMatcher] instead.
3838 factory FileDescriptor (String name, contents) {
39- if (contents is String ) return new _StringFileDescriptor (name, contents);
39+ if (contents is String ) return _StringFileDescriptor (name, contents);
4040 if (contents is List ) {
41- return new _BinaryFileDescriptor (name, contents.cast <int >());
41+ return _BinaryFileDescriptor (name, contents.cast <int >());
4242 }
43- if (contents == null ) return new _BinaryFileDescriptor (name, []);
44- return new _MatcherFileDescriptor (name, contents);
43+ if (contents == null ) return _BinaryFileDescriptor (name, []);
44+ return _MatcherFileDescriptor (name, contents as Matcher );
4545 }
4646
4747 /// Returns a `dart:io` [File] object that refers to this file within
4848 /// [sandbox] .
49- File get io => new File (p.join (sandbox, name));
49+ File get io => File (p.join (sandbox, name));
5050
5151 /// Creates a new binary [FileDescriptor] with [name] that matches its binary
5252 /// contents against [matcher] .
5353 ///
5454 /// The [create] , [read] , and [readAsBytes] methods are unsupported for this
5555 /// descriptor.
5656 factory FileDescriptor .binaryMatcher (String name, Matcher matcher) =>
57- new _MatcherFileDescriptor (name, matcher, isBinary: true );
57+ _MatcherFileDescriptor (name, matcher, isBinary: true );
5858
5959 /// A protected constructor that's only intended for subclasses.
6060 FileDescriptor .protected (String name) : super (name);
6161
6262 Future create ([String parent]) async {
6363 // Create the stream before we call [File.openWrite] because it may fail
6464 // fast (e.g. if this is a matcher file).
65- var file = new File (p.join (parent ?? sandbox, name)).openWrite ();
65+ var file = File (p.join (parent ?? sandbox, name)).openWrite ();
6666 try {
6767 await readAsBytes ().listen (file.add).asFuture ();
6868 } finally {
@@ -73,11 +73,11 @@ abstract class FileDescriptor extends Descriptor {
7373 Future validate ([String parent]) async {
7474 var fullPath = p.join (parent ?? sandbox, name);
7575 var pretty = prettyPath (fullPath);
76- if (! (await new File (fullPath).exists ())) {
76+ if (! (await File (fullPath).exists ())) {
7777 fail ('File not found: "$pretty ".' );
7878 }
7979
80- await _validate (pretty, await new File (fullPath).readAsBytes ());
80+ await _validate (pretty, await File (fullPath).readAsBytes ());
8181 }
8282
8383 /// Validates that [binaryContents] matches the expected contents of
@@ -106,7 +106,7 @@ class _BinaryFileDescriptor extends FileDescriptor {
106106
107107 _BinaryFileDescriptor (String name, this ._contents) : super .protected (name);
108108
109- Stream <List <int >> readAsBytes () => new Stream .fromIterable ([_contents]);
109+ Stream <List <int >> readAsBytes () => Stream .fromIterable ([_contents]);
110110
111111 Future _validate (String prettPath, List <int > actualContents) async {
112112 if (const IterableEquality ().equals (_contents, actualContents)) return null ;
@@ -124,12 +124,12 @@ class _StringFileDescriptor extends FileDescriptor {
124124 Future <String > read () async => _contents;
125125
126126 Stream <List <int >> readAsBytes () =>
127- new Stream .fromIterable ([utf8.encode (_contents)]);
127+ Stream .fromIterable ([utf8.encode (_contents)]);
128128
129129 Future _validate (String prettyPath, List <int > actualContents) {
130130 var actualContentsText = utf8.decode (actualContents);
131131 if (_contents == actualContentsText) return null ;
132- throw fail (_textMismatchMessage (prettyPath, _contents, actualContentsText));
132+ fail (_textMismatchMessage (prettyPath, _contents, actualContentsText));
133133 }
134134
135135 String _textMismatchMessage (
@@ -177,20 +177,19 @@ class _MatcherFileDescriptor extends FileDescriptor {
177177 /// contents.
178178 final bool _isBinary;
179179
180- _MatcherFileDescriptor (String name, this ._matcher, {bool isBinary: false })
180+ _MatcherFileDescriptor (String name, this ._matcher, {bool isBinary = false })
181181 : _isBinary = isBinary,
182182 super .protected (name);
183183
184184 Stream <List <int >> readAsBytes () =>
185- throw new UnsupportedError ("Matcher files can't be created or read." );
185+ throw UnsupportedError ("Matcher files can't be created or read." );
186186
187187 Future _validate (String prettyPath, List <int > actualContents) async {
188188 try {
189189 expect (
190190 _isBinary ? actualContents : utf8.decode (actualContents), _matcher);
191191 } on TestFailure catch (error) {
192- throw new TestFailure (
193- 'Invalid contents for file "$prettyPath ":\n ' + error.message);
192+ fail ('Invalid contents for file "$prettyPath ":\n ${error .message }' );
194193 }
195194 }
196195}
0 commit comments