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

Side by Side Diff: pkg/scheduled_test/test/descriptor/directory_test.dart

Issue 24276010: Change package scheduled_test to throw TestFailures rather than strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove checks and comments on type of exception thrown. Created 7 years, 2 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:path/path.dart' as path; 8 import 'package:path/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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 expectTestsPass("directory().load() fails to load a nested directory", () { 294 expectTestsPass("directory().load() fails to load a nested directory", () {
295 test('test', () { 295 test('test', () {
296 var dir = d.dir('dir', [ 296 var dir = d.dir('dir', [
297 d.dir('subdir', [ 297 d.dir('subdir', [
298 d.file('name.txt', 'subcontents') 298 d.file('name.txt', 'subcontents')
299 ]), 299 ]),
300 d.file('name.txt', 'contents') 300 d.file('name.txt', 'contents')
301 ]); 301 ]);
302 302
303 expect(dir.load('subdir').toList(), 303 expect(dir.load('subdir').toList(), throwsA(predicate(
304 throwsA(equals("Couldn't find a readable entry named 'subdir' within " 304 (x) => x.toString() == "Couldn't find a readable entry named "
305 "'dir'."))); 305 "'subdir' within 'dir'.")));
306 }); 306 });
307 }); 307 });
308 308
309 expectTestsPass("directory().load() fails to load an absolute path", () { 309 expectTestsPass("directory().load() fails to load an absolute path", () {
310 test('test', () { 310 test('test', () {
311 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 311 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
312 312
313 expect(dir.load('/name.txt').toList(), throwsArgumentError); 313 expect(dir.load('/name.txt').toList(), throwsArgumentError);
314 }); 314 });
315 }); 315 });
316 316
317 expectTestsPass("directory().load() fails to load '.', '..', or ''", () { 317 expectTestsPass("directory().load() fails to load '.', '..', or ''", () {
318 test('test', () { 318 test('test', () {
319 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 319 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
320 320
321 expect(dir.load('.').toList(), throwsArgumentError); 321 expect(dir.load('.').toList(), throwsArgumentError);
322 322
323 expect(dir.load('..').toList(), throwsArgumentError); 323 expect(dir.load('..').toList(), throwsArgumentError);
324 324
325 expect(dir.load('').toList(), throwsArgumentError); 325 expect(dir.load('').toList(), throwsArgumentError);
326 }); 326 });
327 }); 327 });
328 328
329 expectTestsPass("directory().load() fails to load a file that doesn't exist", 329 expectTestsPass("directory().load() fails to load a file that doesn't exist",
330 () { 330 () {
331 test('test', () { 331 test('test', () {
332 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 332 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
333 333
334 expect(dir.load('not-name.txt').toList(), 334 expect(dir.load('not-name.txt').toList(), throwsA(predicate(
335 throwsA(equals("Couldn't find a readable entry named 'not-name.txt' " 335 (x) => x.toString() == "Couldn't find a readable entry named "
336 "within 'dir'."))); 336 "'not-name.txt' within 'dir'.")));
337 }); 337 });
338 }); 338 });
339 339
340 expectTestsPass("directory().load() fails to load a file that exists " 340 expectTestsPass("directory().load() fails to load a file that exists "
341 "multiple times", () { 341 "multiple times", () {
342 test('test', () { 342 test('test', () {
343 var dir = d.dir('dir', [ 343 var dir = d.dir('dir', [
344 d.file('name.txt', 'contents'), 344 d.file('name.txt', 'contents'),
345 d.file('name.txt', 'contents') 345 d.file('name.txt', 'contents')
346 ]); 346 ]);
347 347
348 expect(dir.load('name.txt').toList(), 348 expect(dir.load('name.txt').toList(), throwsA(predicate(
349 throwsA(equals("Found multiple readable entries named 'name.txt' " 349 (x) => x.toString() == "Found multiple readable entries named "
350 "within 'dir'."))); 350 "'name.txt' within 'dir'.")));
351 }); 351 });
352 }); 352 });
353 353
354 expectTestsPass("directory().load() loads a file next to a subdirectory with " 354 expectTestsPass("directory().load() loads a file next to a subdirectory with "
355 "the same name", () { 355 "the same name", () {
356 test('test', () { 356 test('test', () {
357 var dir = d.dir('dir', [ 357 var dir = d.dir('dir', [
358 d.file('name', 'contents'), 358 d.file('name', 'contents'),
359 d.dir('name', [d.file('subfile', 'contents')]) 359 d.dir('name', [d.file('subfile', 'contents')])
360 ]); 360 ]);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 "'-- file2.txt")); 405 "'-- file2.txt"));
406 }); 406 });
407 }); 407 });
408 408
409 expectTestsPass("directory().describe() with no contents returns the " 409 expectTestsPass("directory().describe() with no contents returns the "
410 "directory name", () { 410 "directory name", () {
411 test('test', () { 411 test('test', () {
412 expect(d.dir('dir').describe(), equals('dir')); 412 expect(d.dir('dir').describe(), equals('dir'));
413 }); 413 });
414 }); 414 });
415 } 415 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698