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

Side by Side Diff: pkg/unittest/lib/core_matchers.dart

Issue 11301046: Restructure pkg/unittest and pkg/webdriver to follow the pub conventions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of unittest; 5 part of matcher;
6 6
7 /** 7 /**
8 * Returns a matcher that matches empty strings, maps or collections. 8 * Returns a matcher that matches empty strings, maps or collections.
9 */ 9 */
10 const Matcher isEmpty = const _Empty(); 10 const Matcher isEmpty = const _Empty();
11 11
12 class _Empty extends BaseMatcher { 12 class _Empty extends BaseMatcher {
13 const _Empty(); 13 const _Empty();
14 bool matches(item, MatchState matchState) { 14 bool matches(item, MatchState matchState) {
15 if (item is Map || item is Collection) { 15 if (item is Map || item is Collection) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 class Throws extends BaseMatcher { 277 class Throws extends BaseMatcher {
278 final Matcher _matcher; 278 final Matcher _matcher;
279 279
280 const Throws([Matcher matcher]) : 280 const Throws([Matcher matcher]) :
281 this._matcher = matcher; 281 this._matcher = matcher;
282 282
283 bool matches(item, MatchState matchState) { 283 bool matches(item, MatchState matchState) {
284 if (item is Future) { 284 if (item is Future) {
285 // Queue up an asynchronous expectation that validates when the future 285 // Queue up an asynchronous expectation that validates when the future
286 // completes. 286 // completes.
287 item.onComplete(expectAsync1((future) { 287 item.onComplete(_wrapAsync((future) {
288 if (future.hasValue) { 288 if (future.hasValue) {
289 expect(false, isTrue, reason: 289 expect(false, isTrue, reason:
290 "Expected future to fail, but succeeded with '${future.value}'."); 290 "Expected future to fail, but succeeded with '${future.value}'.");
291 } else if (_matcher != null) { 291 } else if (_matcher != null) {
292 var reason; 292 var reason;
293 if (future.stackTrace != null) { 293 if (future.stackTrace != null) {
294 var stackTrace = future.stackTrace.toString(); 294 var stackTrace = future.stackTrace.toString();
295 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; 295 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}";
296 reason = "Actual exception trace:\n$stackTrace"; 296 reason = "Actual exception trace:\n$stackTrace";
297 } 297 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); 689 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher);
690 690
691 Description describeMismatch(item, Description mismatchDescription, 691 Description describeMismatch(item, Description mismatchDescription,
692 MatchState matchState, bool verbose) { 692 MatchState matchState, bool verbose) {
693 mismatchDescription.add(_featureName).add(' '); 693 mismatchDescription.add(_featureName).add(' ');
694 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, 694 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription,
695 matchState.state['innerState'], verbose); 695 matchState.state['innerState'], verbose);
696 return mismatchDescription; 696 return mismatchDescription;
697 } 697 }
698 } 698 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698