Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: pkg/scheduled_test/lib/src/descriptor/file_descriptor.dart

Issue 164883002: pkg/scheduled_test: formatter (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 descriptor.file; 5 library descriptor.file;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math' as math; 10 import 'dart:math' as math;
(...skipping 10 matching lines...) Expand all
21 /// The contents of the file, in bytes. 21 /// The contents of the file, in bytes.
22 final List<int> contents; 22 final List<int> contents;
23 23
24 /// The contents of the file as a String. Assumes UTF-8 encoding. 24 /// The contents of the file as a String. Assumes UTF-8 encoding.
25 String get textContents => new String.fromCharCodes(contents); 25 String get textContents => new String.fromCharCodes(contents);
26 26
27 /// Creates a new text [FileDescriptor] with [name] that matches its String 27 /// Creates a new text [FileDescriptor] with [name] that matches its String
28 /// contents against [matcher]. If the file is created, it's considered to be 28 /// contents against [matcher]. If the file is created, it's considered to be
29 /// empty. 29 /// empty.
30 factory FileDescriptor.matcher(String name, Matcher matcher) => 30 factory FileDescriptor.matcher(String name, Matcher matcher) =>
31 new _MatcherFileDescriptor(name, matcher, isBinary: false); 31 new _MatcherFileDescriptor(name, matcher, isBinary: false);
32 32
33 /// Creates a new binary [FileDescriptor] with [name] that matches its binary 33 /// Creates a new binary [FileDescriptor] with [name] that matches its binary
34 /// contents against [matcher]. If the file is created, it's considered to be 34 /// contents against [matcher]. If the file is created, it's considered to be
35 /// empty. 35 /// empty.
36 factory FileDescriptor.binaryMatcher(String name, Matcher matcher) => 36 factory FileDescriptor.binaryMatcher(String name, Matcher matcher) =>
37 new _MatcherFileDescriptor(name, matcher, isBinary: true); 37 new _MatcherFileDescriptor(name, matcher, isBinary: true);
38 38
39 /// Creates a new binary [FileDescriptor] descriptor with [name] and 39 /// Creates a new binary [FileDescriptor] descriptor with [name] and
40 /// [contents]. 40 /// [contents].
41 factory FileDescriptor.binary(String name, List<int> contents) => 41 factory FileDescriptor.binary(String name, List<int> contents) =>
42 new _BinaryFileDescriptor(name, contents); 42 new _BinaryFileDescriptor(name, contents);
43 43
44 /// Creates a new text [FileDescriptor] with [name] and [contents]. 44 /// Creates a new text [FileDescriptor] with [name] and [contents].
45 factory FileDescriptor(String name, String contents) => 45 factory FileDescriptor(String name, String contents) =>
46 new _StringFileDescriptor(name, contents); 46 new _StringFileDescriptor(name, contents);
47 47
48 FileDescriptor._(String name, this.contents) 48 FileDescriptor._(String name, this.contents)
49 : super(name); 49 : super(name);
50 50
51 Future create([String parent]) => schedule(() { 51 Future create([String parent]) => schedule(() {
52 if (parent == null) parent = defaultRoot; 52 if (parent == null) parent = defaultRoot;
53 return Chain.track(new File(path.join(parent, name)) 53 return Chain.track(new File(path.join(parent, name))
54 .writeAsBytes(contents)); 54 .writeAsBytes(contents));
55 }, "creating file '$name'"); 55 }, "creating file '$name'");
56 56
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 _MatcherFileDescriptor(String name, this._matcher, {bool isBinary}) 143 _MatcherFileDescriptor(String name, this._matcher, {bool isBinary})
144 : _isBinary = isBinary == true ? true : false, 144 : _isBinary = isBinary == true ? true : false,
145 super._(name, <int>[]); 145 super._(name, <int>[]);
146 146
147 void _validateNow(List<int> actualContents) => 147 void _validateNow(List<int> actualContents) =>
148 expect( 148 expect(
149 _isBinary ? actualContents : new String.fromCharCodes(actualContents), 149 _isBinary ? actualContents : new String.fromCharCodes(actualContents),
150 _matcher); 150 _matcher);
151 } 151 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/descriptor.dart ('k') | pkg/scheduled_test/lib/src/substitute_future.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698