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

Side by Side Diff: pkg/expect/lib/minitest.dart

Issue 2419863002: Remove uses of unittest in the HTML tests where possible. (Closed)
Patch Set: Remove TODO. Created 4 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// A minimal, dependency-free emulation layer for a subset of the 5 /// A minimal, dependency-free emulation layer for a subset of the
6 /// unittest/test API used by the language and core library (especially HTML) 6 /// unittest/test API used by the language and core library (especially HTML)
7 /// tests. 7 /// tests.
8 /// 8 ///
9 /// A number of our language and core library tests were written against the 9 /// A number of our language and core library tests were written against the
10 /// unittest package, which is now deprecated in favor of the new test package. 10 /// unittest package, which is now deprecated in favor of the new test package.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 var actualNum = actual as num; 154 var actualNum = actual as num;
155 if (actualNum <= value) { 155 if (actualNum <= value) {
156 fail("Expected $actualNum to be greater than $value."); 156 fail("Expected $actualNum to be greater than $value.");
157 } 157 }
158 }); 158 });
159 159
160 Object same(Object value) => new _Expectation((actual) { 160 Object same(Object value) => new _Expectation((actual) {
161 Expect.identical(value, actual); 161 Expect.identical(value, actual);
162 }); 162 });
163 163
164 Object closeTo(num value, num tolerance) => new _Expectation((actual) {
165 Expect.approxEquals(value, actual, tolerance);
166 });
167
168 /// Succeeds if the actual value is any of the given strings. Unlike matcher's
169 /// [anyOf], this only works with strings and requires an explicit list.
170 Object anyOf(List<String> expected) => new _Expectation((actual) {
171 for (var string in expected) {
172 if (actual == string) return;
173 }
174
175 fail("Expected $actual to be one of $expected.");
176 });
177
164 /// One level of group() nesting to track an optional [setUp()] and [tearDown()] 178 /// One level of group() nesting to track an optional [setUp()] and [tearDown()]
165 /// function for the group. 179 /// function for the group.
166 /// 180 ///
167 /// There is also an implicit top level group. 181 /// There is also an implicit top level group.
168 class _Group { 182 class _Group {
169 _Action setUpFunction; 183 _Action setUpFunction;
170 _Action tearDownFunction; 184 _Action tearDownFunction;
171 } 185 }
172 186
173 /// A wrapper around an expectation function. 187 /// A wrapper around an expectation function.
174 /// 188 ///
175 /// This function is passed the actual value and should throw an 189 /// This function is passed the actual value and should throw an
176 /// [ExpectException] if the value doesn't match the expectation. 190 /// [ExpectException] if the value doesn't match the expectation.
177 class _Expectation { 191 class _Expectation {
178 final _ExpectationFunction function; 192 final _ExpectationFunction function;
179 193
180 _Expectation(this.function); 194 _Expectation(this.function);
181 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698