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

Side by Side Diff: pkg/scheduled_test/test/descriptor/pattern_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: Created 7 years, 3 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 'package:scheduled_test/descriptor.dart' as d; 5 import 'package:scheduled_test/descriptor.dart' as d;
6 import 'package:scheduled_test/scheduled_test.dart'; 6 import 'package:scheduled_test/scheduled_test.dart';
7 7
8 import '../metatest.dart'; 8 import '../metatest.dart';
9 import 'utils.dart'; 9 import 'utils.dart';
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 currentSchedule.onException.schedule(() { 61 currentSchedule.onException.schedule(() {
62 errors = currentSchedule.errors; 62 errors = currentSchedule.errors;
63 }); 63 });
64 64
65 d.filePattern(new RegExp(r'f..'), 'bar').validate(); 65 d.filePattern(new RegExp(r'f..'), 'bar').validate();
66 }); 66 });
67 67
68 test('test 2', () { 68 test('test 2', () {
69 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 69 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
70 expect(errors.length, equals(1)); 70 expect(errors.length, equals(1));
71 expect(errors.first.error, 71 expect(errors.first.error, new isInstanceOf<TestFailure>());
72 expect(errors.first.error.message,
72 matches(r"^No entry found in '[^']+' matching /f\.\./\.$")); 73 matches(r"^No entry found in '[^']+' matching /f\.\./\.$"));
73 }); 74 });
74 }, passing: ['test 2']); 75 }, passing: ['test 2']);
75 76
76 expectTestsPass("pattern().validate() fails if there's a file matching the " 77 expectTestsPass("pattern().validate() fails if there's a file matching the "
77 "pattern but not the entry", () { 78 "pattern but not the entry", () {
78 var errors; 79 var errors;
79 test('test 1', () { 80 test('test 1', () {
80 scheduleSandbox(); 81 scheduleSandbox();
81 82
82 currentSchedule.onException.schedule(() { 83 currentSchedule.onException.schedule(() {
83 errors = currentSchedule.errors; 84 errors = currentSchedule.errors;
84 }); 85 });
85 86
86 d.file('foo', 'bap').create(); 87 d.file('foo', 'bap').create();
87 d.filePattern(new RegExp(r'f..'), 'bar').validate(); 88 d.filePattern(new RegExp(r'f..'), 'bar').validate();
88 }); 89 });
89 90
90 test('test 2', () { 91 test('test 2', () {
91 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 92 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
92 expect(errors.length, equals(1)); 93 expect(errors.length, equals(1));
93 expect(errors.first.error, 94 expect(errors.first.error, new isInstanceOf<TestFailure>());
95 expect(errors.first.error.message,
94 matches(r"^Caught error\n" 96 matches(r"^Caught error\n"
95 r"| File 'foo' should contain:\n" 97 r"| File 'foo' should contain:\n"
96 r"| | bar\n" 98 r"| | bar\n"
97 r"| but actually contained:\n" 99 r"| but actually contained:\n"
98 r"| X bap\n" 100 r"| X bap\n"
99 r"while validating\n" 101 r"while validating\n"
100 r"| foo$")); 102 r"| foo$"));
101 }); 103 });
102 }, passing: ['test 2']); 104 }, passing: ['test 2']);
103 105
(...skipping 12 matching lines...) Expand all
116 ]).create(); 118 ]).create();
117 119
118 d.dirPattern(new RegExp(r'f..'), [ 120 d.dirPattern(new RegExp(r'f..'), [
119 d.file('bar', 'baz') 121 d.file('bar', 'baz')
120 ]).validate(); 122 ]).validate();
121 }); 123 });
122 124
123 test('test 2', () { 125 test('test 2', () {
124 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 126 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
125 expect(errors.length, equals(1)); 127 expect(errors.length, equals(1));
126 expect(errors.first.error, 128 expect(errors.first.error, new isInstanceOf<TestFailure>());
129 expect(errors.first.error.message,
127 matches(r"^Caught error\n" 130 matches(r"^Caught error\n"
128 r"| File 'bar' should contain:\n" 131 r"| File 'bar' should contain:\n"
129 r"| | baz\n" 132 r"| | baz\n"
130 r"| but actually contained:\n" 133 r"| but actually contained:\n"
131 r"| X bap" 134 r"| X bap"
132 r"while validating\n" 135 r"while validating\n"
133 r"| foo\n" 136 r"| foo\n"
134 r"| '-- bar$")); 137 r"| '-- bar$"));
135 }); 138 });
136 }, passing: ['test 2']); 139 }, passing: ['test 2']);
(...skipping 10 matching lines...) Expand all
147 150
148 d.file('foo', 'bar').create(); 151 d.file('foo', 'bar').create();
149 d.file('fee', 'bar').create(); 152 d.file('fee', 'bar').create();
150 d.file('faa', 'bar').create(); 153 d.file('faa', 'bar').create();
151 d.filePattern(new RegExp(r'f..'), 'bar').validate(); 154 d.filePattern(new RegExp(r'f..'), 'bar').validate();
152 }); 155 });
153 156
154 test('test 2', () { 157 test('test 2', () {
155 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 158 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
156 expect(errors.length, equals(1)); 159 expect(errors.length, equals(1));
157 expect(errors.first.error, matches( 160 expect(errors.first.error, new isInstanceOf<TestFailure>());
161 expect(errors.first.error.message, matches(
158 r"^Multiple valid entries found in '[^']+' matching " 162 r"^Multiple valid entries found in '[^']+' matching "
159 r"\/f\.\./:\n" 163 r"\/f\.\./:\n"
160 r"\* faa\n" 164 r"\* faa\n"
161 r"\* fee\n" 165 r"\* fee\n"
162 r"\* foo$")); 166 r"\* foo$"));
163 }); 167 });
164 }, passing: ['test 2']); 168 }, passing: ['test 2']);
165 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698