| OLD | NEW |
| 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'; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 static void indexOperator_hasKey() { | 294 static void indexOperator_hasKey() { |
| 295 var indexResult = makeDatum({ | 295 var indexResult = makeDatum({ |
| 296 'foo': 'bar' | 296 'foo': 'bar' |
| 297 })['foo']; | 297 })['foo']; |
| 298 expect(indexResult, isRequestDatum); | 298 expect(indexResult, isRequestDatum); |
| 299 expect(indexResult.datum, equals('bar')); | 299 expect(indexResult.datum, equals('bar')); |
| 300 expect(indexResult.path, equals('myPath.bar')); | 300 expect(indexResult.path, equals('myPath.bar')); |
| 301 } | 301 } |
| 302 | 302 |
| 303 @runTest |
| 304 static void hasKey() { |
| 305 var datum = makeDatum({ |
| 306 'foo': 'bar' |
| 307 }); |
| 308 expect(datum.hasKey('foo'), isTrue); |
| 309 expect(datum.hasKey('bar'), isFalse); |
| 310 expect(datum.hasKey('baz'), isFalse); |
| 311 } |
| 312 |
| 303 static void forEachMap_nonMap() { | 313 static void forEachMap_nonMap() { |
| 304 expect(() => makeDatum(1).forEachMap((key, value) { | 314 expect(() => makeDatum(1).forEachMap((key, value) { |
| 305 fail('Non-map should not be iterated'); | 315 fail('Non-map should not be iterated'); |
| 306 }), _throwsInvalidParameter); | 316 }), _throwsInvalidParameter); |
| 307 } | 317 } |
| 308 | 318 |
| 309 static void forEachMap_emptyMap() { | 319 static void forEachMap_emptyMap() { |
| 310 makeDatum({}).forEachMap((key, value) { | 320 makeDatum({}).forEachMap((key, value) { |
| 311 fail('Empty map should not be iterated'); | 321 fail('Empty map should not be iterated'); |
| 312 }); | 322 }); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 original.setResult('foo', 'bar'); | 497 original.setResult('foo', 'bar'); |
| 488 Response response = new Response.fromJson(original.toJson()); | 498 Response response = new Response.fromJson(original.toJson()); |
| 489 expect(response.id, equals('myId')); | 499 expect(response.id, equals('myId')); |
| 490 Map<String, Object> result = response.result; | 500 Map<String, Object> result = response.result; |
| 491 expect(result.length, equals(1)); | 501 expect(result.length, equals(1)); |
| 492 expect(result['foo'], equals('bar')); | 502 expect(result['foo'], equals('bar')); |
| 493 } | 503 } |
| 494 } | 504 } |
| 495 | 505 |
| 496 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>()); | 506 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>()); |
| OLD | NEW |