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

Side by Side Diff: pkg/http/test/utils.dart

Issue 11364134: Merge libv1. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error 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
« no previous file with comments | « pkg/http/test/request_test.dart ('k') | pkg/logging/lib/logging.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library utils; 5 library utils;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:json'; 8 import 'dart:json';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 /// A matcher that matches JSON that parses to a value that matches the inner 88 /// A matcher that matches JSON that parses to a value that matches the inner
89 /// matcher. 89 /// matcher.
90 Matcher parse(matcher) => new _Parse(matcher); 90 Matcher parse(matcher) => new _Parse(matcher);
91 91
92 class _Parse extends BaseMatcher { 92 class _Parse extends BaseMatcher {
93 final Matcher _matcher; 93 final Matcher _matcher;
94 94
95 _Parse(this._matcher); 95 _Parse(this._matcher);
96 96
97 bool matches(item, MatchState matchState) { 97 bool matches(item, MatchState matchState) {
98 print("_Parse.matches [$item]");
98 if (item is! String) return false; 99 if (item is! String) return false;
99 100
100 var parsed; 101 var parsed;
101 try { 102 try {
102 parsed = JSON.parse(item); 103 parsed = JSON.parse(item);
103 } catch (e) { 104 } catch (e) {
104 return false; 105 return false;
105 } 106 }
106 107
107 return _matcher.matches(parsed, matchState); 108 return _matcher.matches(parsed, matchState);
(...skipping 22 matching lines...) Expand all
130 const isHttpException = const _HttpException(); 131 const isHttpException = const _HttpException();
131 132
132 /// A matcher for functions that throw HttpException. 133 /// A matcher for functions that throw HttpException.
133 const Matcher throwsHttpException = 134 const Matcher throwsHttpException =
134 const Throws(isHttpException); 135 const Throws(isHttpException);
135 136
136 class _HttpException extends TypeMatcher { 137 class _HttpException extends TypeMatcher {
137 const _HttpException() : super("HttpException"); 138 const _HttpException() : super("HttpException");
138 bool matches(item, MatchState matchState) => item is HttpException; 139 bool matches(item, MatchState matchState) => item is HttpException;
139 } 140 }
OLDNEW
« no previous file with comments | « pkg/http/test/request_test.dart ('k') | pkg/logging/lib/logging.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698