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 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
8 import 'package:scheduled_test/descriptor.dart' as d; | 8 import 'package:scheduled_test/descriptor.dart' as d; |
9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 currentSchedule.onException.schedule(() { | 93 currentSchedule.onException.schedule(() { |
94 errors = currentSchedule.errors; | 94 errors = currentSchedule.errors; |
95 }); | 95 }); |
96 | 96 |
97 d.file('name.txt', 'contents').validate(); | 97 d.file('name.txt', 'contents').validate(); |
98 }); | 98 }); |
99 | 99 |
100 test('test 2', () { | 100 test('test 2', () { |
101 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 101 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
102 expect(errors.length, equals(1)); | 102 expect(errors.length, equals(1)); |
103 expect(errors.first.error, | 103 expect(errors.first.error, new isInstanceOf<TestFailure>()); |
| 104 expect(errors.first.error.message, |
104 matches(r"^File not found: '[^']+[\\/]name\.txt'\.$")); | 105 matches(r"^File not found: '[^']+[\\/]name\.txt'\.$")); |
105 }); | 106 }); |
106 }, passing: ['test 2']); | 107 }, passing: ['test 2']); |
107 | 108 |
108 expectTestsPass("file().read() returns the contents of the file as a stream", | 109 expectTestsPass("file().read() returns the contents of the file as a stream", |
109 () { | 110 () { |
110 test('test', () { | 111 test('test', () { |
111 expect(byteStreamToString(d.file('name.txt', 'contents').read()), | 112 expect(byteStreamToString(d.file('name.txt', 'contents').read()), |
112 completion(equals('contents'))); | 113 completion(equals('contents'))); |
113 }); | 114 }); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 159 |
159 schedule(() { | 160 schedule(() { |
160 return new File(path.join(sandbox, 'name.bin')) | 161 return new File(path.join(sandbox, 'name.bin')) |
161 .writeAsBytes([2, 4, 6, 8, 10]); | 162 .writeAsBytes([2, 4, 6, 8, 10]); |
162 }); | 163 }); |
163 | 164 |
164 d.binaryFile('name.bin', [1, 2, 3, 4, 5]).validate(); | 165 d.binaryFile('name.bin', [1, 2, 3, 4, 5]).validate(); |
165 }); | 166 }); |
166 | 167 |
167 test('test 2', () { | 168 test('test 2', () { |
168 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 169 expect(errors.single, new isInstanceOf<ScheduleError>()); |
169 expect(errors.map((e) => e.error), equals([ | 170 expect(errors.single.error, new isInstanceOf<TestFailure>()); |
170 "File 'name.bin' didn't contain the expected binary data." | 171 expect(errors.single.error.message, equals( |
171 ]), verbose: true); | 172 "File 'name.bin' didn't contain the expected binary data.")); |
172 }); | 173 }); |
173 }, passing: ['test 2']); | 174 }, passing: ['test 2']); |
174 | 175 |
175 expectTestsPass('matcherFile().create() creates an empty file', () { | 176 expectTestsPass('matcherFile().create() creates an empty file', () { |
176 test('test', () { | 177 test('test', () { |
177 scheduleSandbox(); | 178 scheduleSandbox(); |
178 | 179 |
179 d.matcherFile('name.txt', isNot(isEmpty)).create(); | 180 d.matcherFile('name.txt', isNot(isEmpty)).create(); |
180 | 181 |
181 schedule(() { | 182 schedule(() { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 261 |
261 test('test 2', () { | 262 test('test 2', () { |
262 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 263 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
263 expect(errors.map((e) => e.error.message), equals([ | 264 expect(errors.map((e) => e.error.message), equals([ |
264 "Expected: contains <12>\n" | 265 "Expected: contains <12>\n" |
265 " Actual: [98, 97, 114, 102, 111, 111, 98, 97, 122]\n" | 266 " Actual: [98, 97, 114, 102, 111, 111, 98, 97, 122]\n" |
266 ]), verbose: true); | 267 ]), verbose: true); |
267 }); | 268 }); |
268 }, passing: ['test 2']); | 269 }, passing: ['test 2']); |
269 } | 270 } |
OLD | NEW |