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

Side by Side Diff: pkg/analysis_server/test/protocol_test.dart

Issue 228013003: Use mirrors and annotations to find test methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | « pkg/analysis_server/test/declarative_tests.dart ('k') | no next file » | 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.protocol; 5 library test.protocol;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import 'declarative_tests.dart';
13
12 main() { 14 main() {
13 group('Notification', () { 15 addTestSuite(NotificationTest);
14 test('getParameter_defined', NotificationTest.getParameter_defined); 16 addTestSuite(RequestTest);
15 test('getParameter_undefined', NotificationTest.getParameter_undefined); 17 addTestSuite(RequestErrorTest);
16 test('fromJson', NotificationTest.fromJson); 18 addTestSuite(ResponseTest);
17 test('fromJson_withParams', NotificationTest.fromJson_withParams);
18 });
19 group('Request', () {
20 test('getParameter_defined', RequestTest.getParameter_defined);
21 test('getParameter_undefined', RequestTest.getParameter_undefined);
22 test('getRequiredParameter_defined', RequestTest.getRequiredParameter_define d);
23 test('getRequiredParameter_undefined', RequestTest.getRequiredParameter_unde fined);
24 test('fromJson', RequestTest.fromJson);
25 test('fromJson_invalidId', RequestTest.fromJson_invalidId);
26 test('fromJson_invalidMethod', RequestTest.fromJson_invalidMethod);
27 test('fromJson_invalidParams', RequestTest.fromJson_invalidParams);
28 test('fromJson_withParams', RequestTest.fromJson_withParams);
29 test('toBool', RequestTest.toBool);
30 test('toInt', RequestTest.toInt);
31 test('toJson', RequestTest.toJson);
32 test('toJson_withParams', RequestTest.toJson_withParams);
33 });
34 group('RequestError', () {
35 test('create', RequestErrorTest.create);
36 test('create_methodNotFound', RequestErrorTest.create_methodNotFound);
37 test('create_invalidParameters', RequestErrorTest.create_invalidParameters);
38 test('create_invalidRequest', RequestErrorTest.create_invalidRequest);
39 test('create_internalError', RequestErrorTest.create_internalError);
40 test('create_parseError', RequestErrorTest.create_parseError);
41 test('fromJson', RequestErrorTest.fromJson);
42 test('toJson', RequestErrorTest.toJson);
43 });
44 group('Response', () {
45 test('create_contextDoesNotExist', ResponseTest.create_contextDoesNotExist);
46 test('create_invalidRequestFormat', ResponseTest.create_invalidRequestFormat );
47 test('create_missingRequiredParameter', ResponseTest.create_missingRequiredP arameter);
48 test('create_unknownAnalysisOption', ResponseTest.create_unknownAnalysisOpti on);
49 test('create_unknownRequest', ResponseTest.create_unknownRequest);
50 test('setResult', ResponseTest.setResult);
51 test('fromJson', ResponseTest.fromJson);
52 test('fromJson_withError', ResponseTest.fromJson_withError);
53 test('fromJson_withResult', ResponseTest.fromJson_withResult);
54 });
55 } 19 }
56 20
57 class NotificationTest { 21 class NotificationTest {
22 @runTest
58 static void getParameter_defined() { 23 static void getParameter_defined() {
59 Notification notification = new Notification('foo'); 24 Notification notification = new Notification('foo');
60 notification.setParameter('x', 'y'); 25 notification.setParameter('x', 'y');
61 expect(notification.event, equals('foo')); 26 expect(notification.event, equals('foo'));
62 expect(notification.params.length, equals(1)); 27 expect(notification.params.length, equals(1));
63 expect(notification.getParameter('x'), equals('y')); 28 expect(notification.getParameter('x'), equals('y'));
64 expect(notification.toJson(), equals({ 29 expect(notification.toJson(), equals({
65 'event' : 'foo', 30 'event' : 'foo',
66 'params' : {'x' : 'y'} 31 'params' : {'x' : 'y'}
67 })); 32 }));
68 } 33 }
69 34
35 @runTest
70 static void getParameter_undefined() { 36 static void getParameter_undefined() {
71 Notification notification = new Notification('foo'); 37 Notification notification = new Notification('foo');
72 expect(notification.event, equals('foo')); 38 expect(notification.event, equals('foo'));
73 expect(notification.params.length, equals(0)); 39 expect(notification.params.length, equals(0));
74 expect(notification.getParameter('x'), isNull); 40 expect(notification.getParameter('x'), isNull);
75 expect(notification.toJson(), equals({ 41 expect(notification.toJson(), equals({
76 'event' : 'foo' 42 'event' : 'foo'
77 })); 43 }));
78 } 44 }
79 45
46 @runTest
80 static void fromJson() { 47 static void fromJson() {
81 Notification original = new Notification('foo'); 48 Notification original = new Notification('foo');
82 Notification notification = new Notification.fromJson(original.toJson()); 49 Notification notification = new Notification.fromJson(original.toJson());
83 expect(notification.event, equals('foo')); 50 expect(notification.event, equals('foo'));
84 expect(notification.params.length, equals(0)); 51 expect(notification.params.length, equals(0));
85 expect(notification.getParameter('x'), isNull); 52 expect(notification.getParameter('x'), isNull);
86 } 53 }
87 54
55 @runTest
88 static void fromJson_withParams() { 56 static void fromJson_withParams() {
89 Notification original = new Notification('foo'); 57 Notification original = new Notification('foo');
90 original.setParameter('x', 'y'); 58 original.setParameter('x', 'y');
91 Notification notification = new Notification.fromJson(original.toJson()); 59 Notification notification = new Notification.fromJson(original.toJson());
92 expect(notification.event, equals('foo')); 60 expect(notification.event, equals('foo'));
93 expect(notification.params.length, equals(1)); 61 expect(notification.params.length, equals(1));
94 expect(notification.getParameter('x'), equals('y')); 62 expect(notification.getParameter('x'), equals('y'));
95 } 63 }
96 } 64 }
97 65
98 class RequestTest { 66 class RequestTest {
67 @runTest
99 static void getParameter_defined() { 68 static void getParameter_defined() {
100 String name = 'name'; 69 String name = 'name';
101 String value = 'value'; 70 String value = 'value';
102 Request request = new Request('0', ''); 71 Request request = new Request('0', '');
103 request.setParameter(name, value); 72 request.setParameter(name, value);
104 expect(request.getParameter(name), equals(value)); 73 expect(request.getParameter(name), equals(value));
105 } 74 }
106 75
76 @runTest
107 static void getParameter_undefined() { 77 static void getParameter_undefined() {
108 String name = 'name'; 78 String name = 'name';
109 Request request = new Request('0', ''); 79 Request request = new Request('0', '');
110 expect(request.getParameter(name), isNull); 80 expect(request.getParameter(name), isNull);
111 } 81 }
112 82
83 @runTest
113 static void getRequiredParameter_defined() { 84 static void getRequiredParameter_defined() {
114 String name = 'name'; 85 String name = 'name';
115 String value = 'value'; 86 String value = 'value';
116 Request request = new Request('0', ''); 87 Request request = new Request('0', '');
117 request.setParameter(name, value); 88 request.setParameter(name, value);
118 expect(request.getRequiredParameter(name), equals(value)); 89 expect(request.getRequiredParameter(name), equals(value));
119 } 90 }
120 91
92 @runTest
121 static void getRequiredParameter_undefined() { 93 static void getRequiredParameter_undefined() {
122 String name = 'name'; 94 String name = 'name';
123 Request request = new Request('0', ''); 95 Request request = new Request('0', '');
124 expect(() => request.getRequiredParameter(name), _throwsRequestFailure); 96 expect(() => request.getRequiredParameter(name), _throwsRequestFailure);
125 } 97 }
126 98
99 @runTest
127 static void fromJson() { 100 static void fromJson() {
128 Request original = new Request('one', 'aMethod'); 101 Request original = new Request('one', 'aMethod');
129 String json = JSON.encode(original.toJson()); 102 String json = JSON.encode(original.toJson());
130 Request request = new Request.fromString(json); 103 Request request = new Request.fromString(json);
131 expect(request.id, equals('one')); 104 expect(request.id, equals('one'));
132 expect(request.method, equals('aMethod')); 105 expect(request.method, equals('aMethod'));
133 } 106 }
134 107
108 @runTest
135 static void fromJson_invalidId() { 109 static void fromJson_invalidId() {
136 String json = '{"id":{"one":"two"},"method":"aMethod","params":{"foo":"bar"} }'; 110 String json = '{"id":{"one":"two"},"method":"aMethod","params":{"foo":"bar"} }';
137 Request request = new Request.fromString(json); 111 Request request = new Request.fromString(json);
138 expect(request, isNull); 112 expect(request, isNull);
139 } 113 }
140 114
115 @runTest
141 static void fromJson_invalidMethod() { 116 static void fromJson_invalidMethod() {
142 String json = '{"id":"one","method":{"boo":"aMethod"},"params":{"foo":"bar"} }'; 117 String json = '{"id":"one","method":{"boo":"aMethod"},"params":{"foo":"bar"} }';
143 Request request = new Request.fromString(json); 118 Request request = new Request.fromString(json);
144 expect(request, isNull); 119 expect(request, isNull);
145 } 120 }
146 121
122 @runTest
147 static void fromJson_invalidParams() { 123 static void fromJson_invalidParams() {
148 String json = '{"id":"one","method":"aMethod","params":"foobar"}'; 124 String json = '{"id":"one","method":"aMethod","params":"foobar"}';
149 Request request = new Request.fromString(json); 125 Request request = new Request.fromString(json);
150 expect(request, isNull); 126 expect(request, isNull);
151 } 127 }
152 128
129 @runTest
153 static void fromJson_withParams() { 130 static void fromJson_withParams() {
154 Request original = new Request('one', 'aMethod'); 131 Request original = new Request('one', 'aMethod');
155 original.setParameter('foo', 'bar'); 132 original.setParameter('foo', 'bar');
156 String json = JSON.encode(original.toJson()); 133 String json = JSON.encode(original.toJson());
157 Request request = new Request.fromString(json); 134 Request request = new Request.fromString(json);
158 expect(request.id, equals('one')); 135 expect(request.id, equals('one'));
159 expect(request.method, equals('aMethod')); 136 expect(request.method, equals('aMethod'));
160 expect(request.getParameter('foo'), equals('bar')); 137 expect(request.getParameter('foo'), equals('bar'));
161 } 138 }
162 139
140 @runTest
163 static void toBool() { 141 static void toBool() {
164 Request request = new Request('0', ''); 142 Request request = new Request('0', '');
165 expect(request.toBool(true), isTrue); 143 expect(request.toBool(true), isTrue);
166 expect(request.toBool(false), isFalse); 144 expect(request.toBool(false), isFalse);
167 expect(request.toBool('true'), isTrue); 145 expect(request.toBool('true'), isTrue);
168 expect(request.toBool('false'), isFalse); 146 expect(request.toBool('false'), isFalse);
169 expect(request.toBool('abc'), isFalse); 147 expect(request.toBool('abc'), isFalse);
170 expect(() => request.toBool(42), _throwsRequestFailure); 148 expect(() => request.toBool(42), _throwsRequestFailure);
171 } 149 }
172 150
151 @runTest
173 static void toInt() { 152 static void toInt() {
174 Request request = new Request('0', ''); 153 Request request = new Request('0', '');
175 expect(request.toInt(1), equals(1)); 154 expect(request.toInt(1), equals(1));
176 expect(request.toInt('2'), equals(2)); 155 expect(request.toInt('2'), equals(2));
177 expect(() => request.toInt('xxx'), _throwsRequestFailure); 156 expect(() => request.toInt('xxx'), _throwsRequestFailure);
178 expect(() => request.toInt(request), _throwsRequestFailure); 157 expect(() => request.toInt(request), _throwsRequestFailure);
179 } 158 }
180 159
160 @runTest
181 static void toJson() { 161 static void toJson() {
182 Request request = new Request('one', 'aMethod'); 162 Request request = new Request('one', 'aMethod');
183 expect(request.toJson(), equals({ 163 expect(request.toJson(), equals({
184 Request.ID : 'one', 164 Request.ID : 'one',
185 Request.METHOD : 'aMethod' 165 Request.METHOD : 'aMethod'
186 })); 166 }));
187 } 167 }
188 168
169 @runTest
189 static void toJson_withParams() { 170 static void toJson_withParams() {
190 Request request = new Request('one', 'aMethod'); 171 Request request = new Request('one', 'aMethod');
191 request.setParameter('foo', 'bar'); 172 request.setParameter('foo', 'bar');
192 expect(request.toJson(), equals({ 173 expect(request.toJson(), equals({
193 Request.ID : 'one', 174 Request.ID : 'one',
194 Request.METHOD : 'aMethod', 175 Request.METHOD : 'aMethod',
195 Request.PARAMS : {'foo' : 'bar'} 176 Request.PARAMS : {'foo' : 'bar'}
196 })); 177 }));
197 } 178 }
198 } 179 }
199 180
200 class RequestErrorTest { 181 class RequestErrorTest {
182 @runTest
201 static void create() { 183 static void create() {
202 RequestError error = new RequestError(42, 'msg'); 184 RequestError error = new RequestError(42, 'msg');
203 expect(error.code, 42); 185 expect(error.code, 42);
204 expect(error.message, "msg"); 186 expect(error.message, "msg");
205 expect(error.toJson(), equals({ 187 expect(error.toJson(), equals({
206 RequestError.CODE: 42, 188 RequestError.CODE: 42,
207 RequestError.MESSAGE: "msg" 189 RequestError.MESSAGE: "msg"
208 })); 190 }));
209 } 191 }
210 192
193 @runTest
211 static void create_parseError() { 194 static void create_parseError() {
212 RequestError error = new RequestError.parseError(); 195 RequestError error = new RequestError.parseError();
213 expect(error.code, RequestError.CODE_PARSE_ERROR); 196 expect(error.code, RequestError.CODE_PARSE_ERROR);
214 expect(error.message, "Parse error"); 197 expect(error.message, "Parse error");
215 } 198 }
216 199
200 @runTest
217 static void create_methodNotFound() { 201 static void create_methodNotFound() {
218 RequestError error = new RequestError.methodNotFound(); 202 RequestError error = new RequestError.methodNotFound();
219 expect(error.code, RequestError.CODE_METHOD_NOT_FOUND); 203 expect(error.code, RequestError.CODE_METHOD_NOT_FOUND);
220 expect(error.message, "Method not found"); 204 expect(error.message, "Method not found");
221 } 205 }
222 206
207 @runTest
223 static void create_invalidParameters() { 208 static void create_invalidParameters() {
224 RequestError error = new RequestError.invalidParameters(); 209 RequestError error = new RequestError.invalidParameters();
225 expect(error.code, RequestError.CODE_INVALID_PARAMS); 210 expect(error.code, RequestError.CODE_INVALID_PARAMS);
226 expect(error.message, "Invalid parameters"); 211 expect(error.message, "Invalid parameters");
227 } 212 }
228 213
214 @runTest
229 static void create_invalidRequest() { 215 static void create_invalidRequest() {
230 RequestError error = new RequestError.invalidRequest(); 216 RequestError error = new RequestError.invalidRequest();
231 expect(error.code, RequestError.CODE_INVALID_REQUEST); 217 expect(error.code, RequestError.CODE_INVALID_REQUEST);
232 expect(error.message, "Invalid request"); 218 expect(error.message, "Invalid request");
233 } 219 }
234 220
221 @runTest
235 static void create_internalError() { 222 static void create_internalError() {
236 RequestError error = new RequestError.internalError(); 223 RequestError error = new RequestError.internalError();
237 expect(error.code, RequestError.CODE_INTERNAL_ERROR); 224 expect(error.code, RequestError.CODE_INTERNAL_ERROR);
238 expect(error.message, "Internal error"); 225 expect(error.message, "Internal error");
239 } 226 }
240 227
228 @runTest
241 static void fromJson() { 229 static void fromJson() {
242 var json = { 230 var json = {
243 RequestError.CODE: RequestError.CODE_PARSE_ERROR, 231 RequestError.CODE: RequestError.CODE_PARSE_ERROR,
244 RequestError.MESSAGE: 'foo', 232 RequestError.MESSAGE: 'foo',
245 RequestError.DATA: {'ints': [1, 2, 3]} 233 RequestError.DATA: {'ints': [1, 2, 3]}
246 }; 234 };
247 RequestError error = new RequestError.fromJson(json); 235 RequestError error = new RequestError.fromJson(json);
248 expect(error.code, RequestError.CODE_PARSE_ERROR); 236 expect(error.code, RequestError.CODE_PARSE_ERROR);
249 expect(error.message, "foo"); 237 expect(error.message, "foo");
250 expect(error.data['ints'], [1, 2, 3]); 238 expect(error.data['ints'], [1, 2, 3]);
251 expect(error.getData('ints'), [1, 2, 3]); 239 expect(error.getData('ints'), [1, 2, 3]);
252 } 240 }
253 241
242 @runTest
254 static void toJson() { 243 static void toJson() {
255 RequestError error = new RequestError(0, 'msg'); 244 RequestError error = new RequestError(0, 'msg');
256 error.setData('answer', 42); 245 error.setData('answer', 42);
257 error.setData('question', 'unknown'); 246 error.setData('question', 'unknown');
258 expect(error.toJson(), { 247 expect(error.toJson(), {
259 RequestError.CODE: 0, 248 RequestError.CODE: 0,
260 RequestError.MESSAGE: 'msg', 249 RequestError.MESSAGE: 'msg',
261 RequestError.DATA: {'answer': 42, 'question': 'unknown'} 250 RequestError.DATA: {'answer': 42, 'question': 'unknown'}
262 }); 251 });
263 } 252 }
264 } 253 }
265 254
266 class ResponseTest { 255 class ResponseTest {
256 @runTest
267 static void create_contextDoesNotExist() { 257 static void create_contextDoesNotExist() {
268 Response response = new Response.contextDoesNotExist(new Request('0', '')); 258 Response response = new Response.contextDoesNotExist(new Request('0', ''));
269 expect(response.id, equals('0')); 259 expect(response.id, equals('0'));
270 expect(response.error, isNotNull); 260 expect(response.error, isNotNull);
271 expect(response.toJson(), equals({ 261 expect(response.toJson(), equals({
272 Response.ID: '0', 262 Response.ID: '0',
273 Response.ERROR: {'code': -1, 'message': 'Context does not exist'} 263 Response.ERROR: {'code': -1, 'message': 'Context does not exist'}
274 })); 264 }));
275 } 265 }
276 266
267 @runTest
277 static void create_invalidRequestFormat() { 268 static void create_invalidRequestFormat() {
278 Response response = new Response.invalidRequestFormat(); 269 Response response = new Response.invalidRequestFormat();
279 expect(response.id, equals('')); 270 expect(response.id, equals(''));
280 expect(response.error, isNotNull); 271 expect(response.error, isNotNull);
281 expect(response.toJson(), equals({ 272 expect(response.toJson(), equals({
282 Response.ID: '', 273 Response.ID: '',
283 Response.ERROR: {'code': -4, 'message': 'Invalid request'} 274 Response.ERROR: {'code': -4, 'message': 'Invalid request'}
284 })); 275 }));
285 } 276 }
286 277
278 @runTest
287 static void create_missingRequiredParameter() { 279 static void create_missingRequiredParameter() {
288 Response response = new Response.missingRequiredParameter(new Request('0', ' '), 'x'); 280 Response response = new Response.missingRequiredParameter(new Request('0', ' '), 'x');
289 expect(response.id, equals('0')); 281 expect(response.id, equals('0'));
290 expect(response.error, isNotNull); 282 expect(response.error, isNotNull);
291 expect(response.toJson(), equals({ 283 expect(response.toJson(), equals({
292 Response.ID: '0', 284 Response.ID: '0',
293 Response.ERROR: {'code': -5, 'message': 'Missing required parameter: x'} 285 Response.ERROR: {'code': -5, 'message': 'Missing required parameter: x'}
294 })); 286 }));
295 } 287 }
296 288
289 @runTest
297 static void create_unknownAnalysisOption() { 290 static void create_unknownAnalysisOption() {
298 Response response = new Response.unknownAnalysisOption(new Request('0', ''), 'x'); 291 Response response = new Response.unknownAnalysisOption(new Request('0', ''), 'x');
299 expect(response.id, equals('0')); 292 expect(response.id, equals('0'));
300 expect(response.error, isNotNull); 293 expect(response.error, isNotNull);
301 expect(response.toJson(), equals({ 294 expect(response.toJson(), equals({
302 Response.ID: '0', 295 Response.ID: '0',
303 Response.ERROR: {'code': -6, 'message': 'Unknown analysis option: "x"'} 296 Response.ERROR: {'code': -6, 'message': 'Unknown analysis option: "x"'}
304 })); 297 }));
305 } 298 }
306 299
300 @runTest
307 static void create_unknownRequest() { 301 static void create_unknownRequest() {
308 Response response = new Response.unknownRequest(new Request('0', '')); 302 Response response = new Response.unknownRequest(new Request('0', ''));
309 expect(response.id, equals('0')); 303 expect(response.id, equals('0'));
310 expect(response.error, isNotNull); 304 expect(response.error, isNotNull);
311 expect(response.toJson(), equals({ 305 expect(response.toJson(), equals({
312 Response.ID: '0', 306 Response.ID: '0',
313 Response.ERROR: {'code': -7, 'message': 'Unknown request'} 307 Response.ERROR: {'code': -7, 'message': 'Unknown request'}
314 })); 308 }));
315 } 309 }
316 310
311 @runTest
317 static void setResult() { 312 static void setResult() {
318 String resultName = 'name'; 313 String resultName = 'name';
319 String resultValue = 'value'; 314 String resultValue = 'value';
320 Response response = new Response('0'); 315 Response response = new Response('0');
321 response.setResult(resultName, resultValue); 316 response.setResult(resultName, resultValue);
322 expect(response.getResult(resultName), same(resultValue)); 317 expect(response.getResult(resultName), same(resultValue));
323 expect(response.toJson(), equals({ 318 expect(response.toJson(), equals({
324 Response.ID: '0', 319 Response.ID: '0',
325 Response.ERROR: null, 320 Response.ERROR: null,
326 Response.RESULT: { 321 Response.RESULT: {
327 resultName: resultValue 322 resultName: resultValue
328 } 323 }
329 })); 324 }));
330 } 325 }
331 326
327 @runTest
332 static void fromJson() { 328 static void fromJson() {
333 Response original = new Response('myId'); 329 Response original = new Response('myId');
334 Response response = new Response.fromJson(original.toJson()); 330 Response response = new Response.fromJson(original.toJson());
335 expect(response.id, equals('myId')); 331 expect(response.id, equals('myId'));
336 } 332 }
337 333
334 @runTest
338 static void fromJson_withError() { 335 static void fromJson_withError() {
339 Response original = new Response.invalidRequestFormat(); 336 Response original = new Response.invalidRequestFormat();
340 Response response = new Response.fromJson(original.toJson()); 337 Response response = new Response.fromJson(original.toJson());
341 expect(response.id, equals('')); 338 expect(response.id, equals(''));
342 expect(response.error, isNotNull); 339 expect(response.error, isNotNull);
343 RequestError error = response.error; 340 RequestError error = response.error;
344 expect(error.code, equals(-4)); 341 expect(error.code, equals(-4));
345 expect(error.message, equals('Invalid request')); 342 expect(error.message, equals('Invalid request'));
346 } 343 }
347 344
345 @runTest
348 static void fromJson_withResult() { 346 static void fromJson_withResult() {
349 Response original = new Response('myId'); 347 Response original = new Response('myId');
350 original.setResult('foo', 'bar'); 348 original.setResult('foo', 'bar');
351 Response response = new Response.fromJson(original.toJson()); 349 Response response = new Response.fromJson(original.toJson());
352 expect(response.id, equals('myId')); 350 expect(response.id, equals('myId'));
353 Map<String, Object> result = response.result; 351 Map<String, Object> result = response.result;
354 expect(result.length, equals(1)); 352 expect(result.length, equals(1));
355 expect(result['foo'], equals('bar')); 353 expect(result['foo'], equals('bar'));
356 } 354 }
357 } 355 }
358 356
359 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>()); 357 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>());
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/declarative_tests.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698