Chromium Code Reviews| 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:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:pathos/path.dart' as path; | 8 import 'package:pathos/path.dart' as path; |
| 9 import 'package:scheduled_test/descriptor.dart' as d; | 9 import 'package:scheduled_test/descriptor.dart' as d; |
| 10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 d.binaryFile('name.bin', [1, 2, 3, 4, 5]).validate(); | 173 d.binaryFile('name.bin', [1, 2, 3, 4, 5]).validate(); |
| 174 }); | 174 }); |
| 175 | 175 |
| 176 test('test 2', () { | 176 test('test 2', () { |
| 177 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 177 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 178 expect(errors.map((e) => e.error), equals([ | 178 expect(errors.map((e) => e.error), equals([ |
| 179 "File 'name.bin' didn't contain the expected binary data." | 179 "File 'name.bin' didn't contain the expected binary data." |
| 180 ]), verbose: true); | 180 ]), verbose: true); |
| 181 }); | 181 }); |
| 182 }, passing: ['test 2']); | 182 }, passing: ['test 2']); |
| 183 } | 183 |
| 184 expectTestsPass('matcherFile().create() creates an empty file', () { | |
| 185 test('test', () { | |
| 186 scheduleSandbox(); | |
|
Andrei Mouravski
2013/05/09 00:08:14
Why not pull the schedule into a global group's se
nweiz
2013/05/09 00:15:12
That doesn't work with metatest. Each call to [exp
| |
| 187 | |
| 188 d.matcherFile('name.txt', isNot(isEmpty)).create(); | |
| 189 | |
| 190 schedule(() { | |
| 191 expect(new File(path.join(sandbox, 'name.txt')).readAsString(), | |
| 192 completion(equals(''))); | |
| 193 }); | |
| 194 }); | |
| 195 }); | |
| 196 | |
| 197 expectTestsPass('matcherFile().validate() completes successfully if the ' | |
| 198 'string contents of the file matches the matcher', () { | |
| 199 test('test', () { | |
| 200 scheduleSandbox(); | |
| 201 | |
| 202 schedule(() { | |
| 203 return new File(path.join(sandbox, 'name.txt')) | |
| 204 .writeAsString('barfoobaz'); | |
| 205 }); | |
| 206 | |
| 207 d.matcherFile('name.txt', contains('foo')).validate(); | |
| 208 }); | |
| 209 }); | |
| 210 | |
| 211 expectTestsPass("matcherFile().validate() fails if the string contents of " | |
| 212 "the file doesn't match the matcher", () { | |
| 213 var errors; | |
| 214 test('test 1', () { | |
| 215 scheduleSandbox(); | |
| 216 | |
| 217 currentSchedule.onException.schedule(() { | |
| 218 errors = currentSchedule.errors; | |
| 219 }); | |
| 220 | |
| 221 schedule(() { | |
| 222 return new File(path.join(sandbox, 'name.txt')) | |
| 223 .writeAsString('barfoobaz'); | |
| 224 }); | |
| 225 | |
| 226 d.matcherFile('name.txt', contains('baaz')).validate(); | |
| 227 }); | |
| 228 | |
| 229 test('test 2', () { | |
| 230 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | |
| 231 expect(errors.map((e) => e.error.message), equals([ | |
| 232 "Expected: contains 'baaz'\n but: was 'barfoobaz'.\n" | |
| 233 ]), verbose: true); | |
| 234 }); | |
| 235 }, passing: ['test 2']); | |
| 236 | |
| 237 expectTestsPass('binaryMatcherFile().validate() completes successfully if ' | |
| 238 'the string contents of the file matches the matcher', () { | |
| 239 test('test', () { | |
| 240 scheduleSandbox(); | |
| 241 | |
| 242 schedule(() { | |
| 243 return new File(path.join(sandbox, 'name.txt')) | |
| 244 .writeAsString('barfoobaz'); | |
| 245 }); | |
| 246 | |
| 247 d.binaryMatcherFile('name.txt', contains(111)).validate(); | |
| 248 }); | |
| 249 }); | |
| 250 | |
| 251 expectTestsPass("binaryMatcherFile().validate() fails if the string contents " | |
|
Andrei Mouravski
2013/05/09 00:08:14
Use ' instead of " here and elsewhere.
nweiz
2013/05/09 00:15:12
This needs to be double quotes because it contains
| |
| 252 "of the file doesn't match the matcher", () { | |
| 253 var errors; | |
| 254 test('test 1', () { | |
| 255 scheduleSandbox(); | |
| 256 | |
| 257 currentSchedule.onException.schedule(() { | |
| 258 errors = currentSchedule.errors; | |
| 259 }); | |
| 260 | |
| 261 schedule(() { | |
| 262 return new File(path.join(sandbox, 'name.txt')) | |
| 263 .writeAsString('barfoobaz'); | |
| 264 }); | |
| 265 | |
| 266 d.binaryMatcherFile('name.txt', contains(12)).validate(); | |
| 267 }); | |
| 268 | |
| 269 test('test 2', () { | |
| 270 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | |
| 271 expect(errors.map((e) => e.error.message), equals([ | |
| 272 "Expected: contains <12>\n" | |
| 273 " but: was <[98, 97, 114, 102, 111, 111, 98, 97, 122]>.\n" | |
| 274 ]), verbose: true); | |
| 275 }); | |
| 276 }, passing: ['test 2']); | |
| 277 } | |
| OLD | NEW |