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

Side by Side Diff: pkg/analysis_server/lib/src/protocol.dart

Issue 281373002: add RequestDatum tests and fix some situations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 7 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/protocol_test.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 protocol; 5 library protocol;
6 6
7 import 'dart:convert' show JsonDecoder; 7 import 'dart:convert' show JsonDecoder;
8 8
9 /** 9 /**
10 * Instances of the class [Request] represent a request that was received. 10 * Instances of the class [Request] represent a request that was received.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 * Validate that the datum is a boolean (or a string that can be parsed 230 * Validate that the datum is a boolean (or a string that can be parsed
231 * as a boolean), and return the bool. 231 * as a boolean), and return the bool.
232 * 232 *
233 * The value is typically the result of invoking either [getParameter] or 233 * The value is typically the result of invoking either [getParameter] or
234 * [getRequiredParameter]. 234 * [getRequiredParameter].
235 */ 235 */
236 bool asBool() { 236 bool asBool() {
237 if (datum is bool) { 237 if (datum is bool) {
238 return datum; 238 return datum;
239 } else if (datum == 'true') { 239 } else if (datum == 'true') {
240 return datum == 'true'; 240 return true;
241 } else if (datum == 'false') { 241 } else if (datum == 'false') {
242 return datum == 'false'; 242 return false;
243 } 243 }
244 throw new RequestFailure(new Response.invalidParameter(request, datum, 244 throw new RequestFailure(new Response.invalidParameter(request, datum,
245 "be a boolean")); 245 "be a boolean"));
246 } 246 }
247 247
248 /** 248 /**
249 * Validate that the datum is a string, and return it. 249 * Validate that the datum is a string, and return it.
250 */ 250 */
251 String asString() { 251 String asString() {
252 if (datum is! String) { 252 if (datum is! String) {
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 /** 704 /**
705 * The response to be returned as a result of the failure. 705 * The response to be returned as a result of the failure.
706 */ 706 */
707 final Response response; 707 final Response response;
708 708
709 /** 709 /**
710 * Initialize a newly created exception to return the given reponse. 710 * Initialize a newly created exception to return the given reponse.
711 */ 711 */
712 RequestFailure(this.response); 712 RequestFailure(this.response);
713 } 713 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698