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

Unified Diff: tests/lib/unittest/testers.dart

Issue 10545167: Some unit test fixes: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: tests/lib/unittest/testers.dart
===================================================================
--- tests/lib/unittest/testers.dart (revision 0)
+++ tests/lib/unittest/testers.dart (revision 0)
@@ -0,0 +1,43 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
Siggi Cherem (dart-lang) 2012/06/13 23:43:53 let's rename this file, ideas: - test_utils.dart -
gram 2012/06/14 00:50:58 Done.
+int errorCount;
+String errorString;
+var _testHandler = null;
+
+class MyFailureHandler extends DefaultFailureHandler {
+ void fail(String reason) {
+ ++errorCount;
+ errorString = reason;
+ }
+}
+
+void initTesters() {
Siggi Cherem (dart-lang) 2012/06/13 23:43:53 rename according to file rename...
gram 2012/06/14 00:50:58 Done.
+ if (_testHandler == null) {
+ _testHandler = new MyFailureHandler();
+ }
+}
+
+void shouldFail(var value, Matcher matcher, expected) {
Bob Nystrom 2012/06/13 23:52:29 Don't need "var" here.
gram 2012/06/14 00:50:58 Done.
+ configureExpectHandler(_testHandler);
+ errorCount = 0;
+ errorString = '';
+ expect(value, matcher);
+ configureExpectHandler(null);
+ expect(errorCount, equals(1));
+ if (expected is String)
Bob Nystrom 2012/06/13 23:52:29 Multi-line ifs should use curlies.
gram 2012/06/14 00:50:58 Done.
+ expect(errorString, equalsIgnoringWhitespace(expected));
+ else
+ expect(errorString, expected);
+}
+
+void shouldPass(var value, Matcher matcher) {
+ configureExpectHandler(_testHandler);
+ errorCount = 0;
+ errorString = '';
+ expect(value, matcher);
+ configureExpectHandler(null);
+ expect(errorCount, equals(0));
+}
+
Siggi Cherem (dart-lang) 2012/06/13 23:43:53 empty line

Powered by Google App Engine
This is Rietveld 408576698