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

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: 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 '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.toString(),
72 matches(r"^No entry found in '[^']+' matching /f\.\./\.$")); 72 matches(r"^No entry found in '[^']+' matching /f\.\./\.$"));
73 }); 73 });
74 }, passing: ['test 2']); 74 }, passing: ['test 2']);
75 75
76 expectTestsPass("pattern().validate() fails if there's a file matching the " 76 expectTestsPass("pattern().validate() fails if there's a file matching the "
77 "pattern but not the entry", () { 77 "pattern but not the entry", () {
78 var errors; 78 var errors;
79 test('test 1', () { 79 test('test 1', () {
80 scheduleSandbox(); 80 scheduleSandbox();
81 81
82 currentSchedule.onException.schedule(() { 82 currentSchedule.onException.schedule(() {
83 errors = currentSchedule.errors; 83 errors = currentSchedule.errors;
84 }); 84 });
85 85
86 d.file('foo', 'bap').create(); 86 d.file('foo', 'bap').create();
87 d.filePattern(new RegExp(r'f..'), 'bar').validate(); 87 d.filePattern(new RegExp(r'f..'), 'bar').validate();
88 }); 88 });
89 89
90 test('test 2', () { 90 test('test 2', () {
91 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 91 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
92 expect(errors.length, equals(1)); 92 expect(errors.length, equals(1));
93 expect(errors.first.error, 93 expect(errors.first.error.toString(),
94 matches(r"^Caught error\n" 94 matches(r"^Caught error\n"
95 r"| File 'foo' should contain:\n" 95 r"| File 'foo' should contain:\n"
96 r"| | bar\n" 96 r"| | bar\n"
97 r"| but actually contained:\n" 97 r"| but actually contained:\n"
98 r"| X bap\n" 98 r"| X bap\n"
99 r"while validating\n" 99 r"while validating\n"
100 r"| foo$")); 100 r"| foo$"));
101 }); 101 });
102 }, passing: ['test 2']); 102 }, passing: ['test 2']);
103 103
(...skipping 12 matching lines...) Expand all
116 ]).create(); 116 ]).create();
117 117
118 d.dirPattern(new RegExp(r'f..'), [ 118 d.dirPattern(new RegExp(r'f..'), [
119 d.file('bar', 'baz') 119 d.file('bar', 'baz')
120 ]).validate(); 120 ]).validate();
121 }); 121 });
122 122
123 test('test 2', () { 123 test('test 2', () {
124 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 124 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
125 expect(errors.length, equals(1)); 125 expect(errors.length, equals(1));
126 expect(errors.first.error, 126 expect(errors.first.error.toString(),
127 matches(r"^Caught error\n" 127 matches(r"^Caught error\n"
128 r"| File 'bar' should contain:\n" 128 r"| File 'bar' should contain:\n"
129 r"| | baz\n" 129 r"| | baz\n"
130 r"| but actually contained:\n" 130 r"| but actually contained:\n"
131 r"| X bap" 131 r"| X bap"
132 r"while validating\n" 132 r"while validating\n"
133 r"| foo\n" 133 r"| foo\n"
134 r"| '-- bar$")); 134 r"| '-- bar$"));
135 }); 135 });
136 }, passing: ['test 2']); 136 }, passing: ['test 2']);
(...skipping 10 matching lines...) Expand all
147 147
148 d.file('foo', 'bar').create(); 148 d.file('foo', 'bar').create();
149 d.file('fee', 'bar').create(); 149 d.file('fee', 'bar').create();
150 d.file('faa', 'bar').create(); 150 d.file('faa', 'bar').create();
151 d.filePattern(new RegExp(r'f..'), 'bar').validate(); 151 d.filePattern(new RegExp(r'f..'), 'bar').validate();
152 }); 152 });
153 153
154 test('test 2', () { 154 test('test 2', () {
155 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 155 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
156 expect(errors.length, equals(1)); 156 expect(errors.length, equals(1));
157 expect(errors.first.error, matches( 157 expect(errors.first.error.toString(), matches(
158 r"^Multiple valid entries found in '[^']+' matching " 158 r"^Multiple valid entries found in '[^']+' matching "
159 r"\/f\.\./:\n" 159 r"\/f\.\./:\n"
160 r"\* faa\n" 160 r"\* faa\n"
161 r"\* fee\n" 161 r"\* fee\n"
162 r"\* foo$")); 162 r"\* foo$"));
163 }); 163 });
164 }, passing: ['test 2']); 164 }, passing: ['test 2']);
165 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698