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

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

Powered by Google App Engine
This is Rietveld 408576698