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

Side by Side Diff: pkg/analysis_server/test/integration/integration_tests.dart

Issue 459643002: Improve matchers for enums defined by the analysis server API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/protocol_matchers.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 test.integration.analysis; 5 library test.integration.analysis;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 mismatchDescription = mismatchDescription.add('; ').add(subDescription 281 mismatchDescription = mismatchDescription.add('; ').add(subDescription
282 ); 282 );
283 } 283 }
284 return mismatchDescription.add(')'); 284 return mismatchDescription.add(')');
285 }); 285 });
286 } 286 }
287 } 287 }
288 } 288 }
289 289
290 /** 290 /**
291 * Matcher that matches a String drawn from a limited set.
292 */
293 class MatchesEnum extends Matcher {
294 /**
295 * Short description of the expected type.
296 */
297 final String description;
298
299 /**
300 * The set of enum values that are allowed.
301 */
302 final List<String> allowedValues;
303
304 const MatchesEnum(this.description, this.allowedValues);
305
306 @override
307 bool matches(item, Map matchState) {
308 return allowedValues.contains(item);
309 }
310
311 @override
312 Description describe(Description description) => description.add(
313 this.description);
314 }
315
316 /**
291 * Matcher that matches a JSON object, with a given set of required and 317 * Matcher that matches a JSON object, with a given set of required and
292 * optional fields, and their associated types (expressed as [Matcher]s). 318 * optional fields, and their associated types (expressed as [Matcher]s).
293 */ 319 */
294 class MatchesJsonObject extends _RecursiveMatcher { 320 class MatchesJsonObject extends _RecursiveMatcher {
295 /** 321 /**
296 * Short description of the expected type. 322 * Short description of the expected type.
297 */ 323 */
298 final String description; 324 final String description;
299 325
300 /** 326 /**
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 */ 716 */
691 void _recordStdio(String line) { 717 void _recordStdio(String line) {
692 double elapsedTime = _time.elapsedTicks / _time.frequency; 718 double elapsedTime = _time.elapsedTicks / _time.frequency;
693 line = "$elapsedTime: $line"; 719 line = "$elapsedTime: $line";
694 if (_debuggingStdio) { 720 if (_debuggingStdio) {
695 print(line); 721 print(line);
696 } 722 }
697 _recordedStdio.add(line); 723 _recordedStdio.add(line);
698 } 724 }
699 } 725 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/protocol_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698