| Index: pkg/analysis_server/test/protocol_test.dart
|
| diff --git a/pkg/analysis_server/test/protocol_test.dart b/pkg/analysis_server/test/protocol_test.dart
|
| index c46249bd6a366558fffd70999589fa246807ce5b..76768b9d127d65b744d094f3d478ebb190541b23 100644
|
| --- a/pkg/analysis_server/test/protocol_test.dart
|
| +++ b/pkg/analysis_server/test/protocol_test.dart
|
| @@ -20,7 +20,6 @@ main() {
|
| runReflectiveTests(NotificationTest);
|
| runReflectiveTests(RequestTest);
|
| runReflectiveTests(RequestErrorTest);
|
| - runReflectiveTests(RequestDatumTest);
|
| runReflectiveTests(ResponseTest);
|
| }
|
|
|
| @@ -134,266 +133,6 @@ class _MyHasToJsonObject implements HasToJson {
|
|
|
|
|
| @ReflectiveTestCase()
|
| -class RequestDatumTest {
|
| - static Matcher isRequestDatum = new isInstanceOf<RequestDatum>(
|
| - "RequestDatum");
|
| -
|
| - static Request request;
|
| - static Matcher _throwsInvalidParameter = throwsA(
|
| - new InvalidParameterResponseMatcher());
|
| -
|
| - void setUp() {
|
| - request = new Request('myId', 'myMethod');
|
| - }
|
| -
|
| - void test_asBool() {
|
| - expect(makeDatum(true).asBool(), isTrue);
|
| - expect(makeDatum(false).asBool(), isFalse);
|
| - expect(makeDatum('true').asBool(), isTrue);
|
| - expect(makeDatum('false').asBool(), isFalse);
|
| - expect(() => makeDatum('abc').asBool(), _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_asInt() {
|
| - expect(makeDatum(1).asInt(), equals(1));
|
| - expect(makeDatum('2').asInt(), equals(2));
|
| - expect(() => makeDatum('xxx').asInt(), _throwsInvalidParameter);
|
| - expect(() => makeDatum(true).asInt(), _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_asList_emptyList() {
|
| - expect(makeDatum([]).asList((datum) => datum.asString()), equals([]));
|
| - }
|
| -
|
| - void test_asList_nonEmptyList() {
|
| - expect(makeDatum(['foo', 'bar']).asList((datum) => datum.asString()),
|
| - equals(['foo', 'bar']));
|
| - }
|
| -
|
| - void test_asList_nonList() {
|
| - expect(() => makeDatum(3).asList((datum) => null), _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_asList_null() {
|
| - expect(makeDatum(null).asList((datum) => datum.asString()), equals([]));
|
| - }
|
| -
|
| - void test_asString() {
|
| - expect(makeDatum('foo').asString(), equals('foo'));
|
| - expect(() => makeDatum(3).asString(), _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_asStringList() {
|
| - expect(makeDatum(['foo', 'bar']).asStringList(), equals(['foo', 'bar']));
|
| - expect(makeDatum([]).asStringList(), equals([]));
|
| - expect(makeDatum(null).asStringList(), equals([]));
|
| - expect(() => makeDatum(['foo', 1]).asStringList(), _throwsInvalidParameter);
|
| - expect(() => makeDatum({}).asStringList(), _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_asStringListMap() {
|
| - {
|
| - var map = {
|
| - 'key1': ['value11', 'value12'],
|
| - 'key2': ['value21', 'value22']
|
| - };
|
| - expect(makeDatum(map).asStringListMap(), map);
|
| - }
|
| - {
|
| - var map = {
|
| - 'key1': 10,
|
| - 'key2': 20
|
| - };
|
| - expect(() => makeDatum(map).asStringListMap(), _throwsInvalidParameter);
|
| - }
|
| - {
|
| - var map = {
|
| - 'key1': [11, 12],
|
| - 'key2': [21, 22]
|
| - };
|
| - expect(() => makeDatum(map).asStringListMap(), _throwsInvalidParameter);
|
| - }
|
| - }
|
| -
|
| - void test_asStringMap() {
|
| - expect(makeDatum({
|
| - 'key1': 'value1',
|
| - 'key2': 'value2'
|
| - }).asStringMap(), equals({
|
| - 'key1': 'value1',
|
| - 'key2': 'value2'
|
| - }));
|
| - expect(makeDatum({}).asStringMap(), equals({}));
|
| - expect(() => makeDatum({
|
| - 'key1': 'value1',
|
| - 'key2': 2
|
| - }).asStringMap(), _throwsInvalidParameter);
|
| - expect(() => makeDatum({
|
| - 'key1': 1,
|
| - 'key2': 2
|
| - }).asStringMap(), _throwsInvalidParameter);
|
| - expect(() => makeDatum([]).asStringMap(), _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_forEachMap_emptyMap() {
|
| - makeDatum({}).forEachMap((key, value) {
|
| - fail('Empty map should not be iterated');
|
| - });
|
| - }
|
| -
|
| - void test_forEachMap_nonMap() {
|
| - expect(() => makeDatum(1).forEachMap((key, value) {
|
| - fail('Non-map should not be iterated');
|
| - }), _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_forEachMap_null() {
|
| - makeDatum(null).forEachMap((key, value) {
|
| - fail('Empty map should not be iterated');
|
| - });
|
| - }
|
| -
|
| - void test_forEachMap_oneElementMap() {
|
| - int callCount = 0;
|
| - makeDatum({
|
| - 'key': 'value'
|
| - }).forEachMap((key, value) {
|
| - callCount++;
|
| - expect(key, equals('key'));
|
| - expect(value, isRequestDatum);
|
| - expect(value.datum, equals('value'));
|
| - });
|
| - expect(callCount, equals(1));
|
| - }
|
| -
|
| - void test_forEachMap_twoElementMap() {
|
| - int callCount = 0;
|
| - Map<String, String> map = {
|
| - 'key1': 'value1',
|
| - 'key2': 'value2'
|
| - };
|
| - Map iterationResult = {};
|
| - makeDatum(map).forEachMap((key, value) {
|
| - callCount++;
|
| - expect(value, isRequestDatum);
|
| - iterationResult[key] = value.datum;
|
| - });
|
| - expect(callCount, equals(2));
|
| - expect(iterationResult, equals(map));
|
| - }
|
| -
|
| - void test_hasKey() {
|
| - var datum = makeDatum({
|
| - 'foo': 'bar'
|
| - });
|
| - expect(datum.hasKey('foo'), isTrue);
|
| - expect(datum.hasKey('bar'), isFalse);
|
| - expect(datum.hasKey('baz'), isFalse);
|
| - }
|
| -
|
| - void test_hasKey_null() {
|
| - expect(makeDatum(null).hasKey('foo'), isFalse);
|
| - }
|
| -
|
| - void test_indexOperator_hasKey() {
|
| - var indexResult = makeDatum({
|
| - 'foo': 'bar'
|
| - })['foo'];
|
| - expect(indexResult, isRequestDatum);
|
| - expect(indexResult.datum, equals('bar'));
|
| - expect(indexResult.path, equals('myPath.foo'));
|
| - }
|
| -
|
| - void test_indexOperator_missingKey() {
|
| - expect(() => makeDatum({
|
| - 'foo': 'bar'
|
| - })['baz'], _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_indexOperator_nonMap() {
|
| - expect(() => makeDatum(1)['foo'], _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_indexOperator_null() {
|
| - expect(() => makeDatum(null)['foo'], _throwsInvalidParameter);
|
| - }
|
| -
|
| - void test_isList() {
|
| - expect(makeDatum(3).isList, isFalse);
|
| - expect(makeDatum(null).isList, isTrue);
|
| - expect(makeDatum([]).isList, isTrue);
|
| - expect(makeDatum(['foo', 'bar']).isList, isTrue);
|
| - }
|
| -
|
| - void test_isMap() {
|
| - expect(makeDatum({
|
| - 'key1': 'value1',
|
| - 'key2': 'value2'
|
| - }).isMap, isTrue);
|
| - expect(makeDatum({}).isMap, isTrue);
|
| - expect(makeDatum(null).isMap, isTrue);
|
| - expect(makeDatum({
|
| - 'key1': 'value1',
|
| - 'key2': 2
|
| - }).isMap, isTrue);
|
| - expect(makeDatum({
|
| - 'key1': 1,
|
| - 'key2': 2
|
| - }).isMap, isTrue);
|
| - expect(makeDatum([]).isMap, isFalse);
|
| - }
|
| -
|
| - void test_isStringList() {
|
| - expect(makeDatum(['foo', 'bar']).isStringList, isTrue);
|
| - expect(makeDatum([]).isStringList, isTrue);
|
| - expect(makeDatum(null).isStringList, isTrue);
|
| - expect(makeDatum(['foo', 1]).isStringList, isFalse);
|
| - expect(makeDatum({}).isStringList, isFalse);
|
| - }
|
| -
|
| - void test_isStringListMap() {
|
| - expect(makeDatum({
|
| - 'key1': ['value11', 'value12'],
|
| - 'key2': ['value21', 'value22']
|
| - }).isStringListMap, isTrue);
|
| - expect(makeDatum({
|
| - 'key1': 10,
|
| - 'key2': 20
|
| - }).isStringListMap, isFalse);
|
| - expect(makeDatum({
|
| - 'key1': [11, 12],
|
| - 'key2': [21, 22]
|
| - }).isStringListMap, isFalse);
|
| - expect(makeDatum({}).isStringListMap, isTrue);
|
| - expect(makeDatum(null).isStringListMap, isTrue);
|
| - expect(makeDatum(3).isStringListMap, isFalse);
|
| - }
|
| -
|
| - void test_isStringMap() {
|
| - expect(makeDatum({
|
| - 'key1': 'value1',
|
| - 'key2': 'value2'
|
| - }).isStringMap, isTrue);
|
| - expect(makeDatum({}).isStringMap, isTrue);
|
| - expect(makeDatum(null).isStringMap, isTrue);
|
| - expect(makeDatum({
|
| - 'key1': 'value1',
|
| - 'key2': 2
|
| - }).isStringMap, isFalse);
|
| - expect(makeDatum({
|
| - 'key1': 1,
|
| - 'key2': 2
|
| - }).isStringMap, isFalse);
|
| - expect(makeDatum([]).isMap, isFalse);
|
| - }
|
| -
|
| - static RequestDatum makeDatum(dynamic datum) {
|
| - return new RequestDatum(request, 'myPath', datum);
|
| - }
|
| -}
|
| -
|
| -
|
| -@ReflectiveTestCase()
|
| class RequestErrorTest {
|
| void test_create() {
|
| RequestError error = new RequestError('ERROR_CODE', 'msg');
|
| @@ -511,25 +250,6 @@ class RequestTest {
|
| expect(request.params, equals({'foo': 'bar'}));
|
| }
|
|
|
| - void test_getRequiredParameter_defined() {
|
| - String name = 'name';
|
| - String value = 'value';
|
| - Request request = new Request('0', '', {name: value});
|
| - expect(request.getRequiredParameter(name).datum, equals(value));
|
| - }
|
| -
|
| - void test_getRequiredParameter_null() {
|
| - String name = 'name';
|
| - Request request = new Request('0', '', {name: null});
|
| - expect(request.getRequiredParameter(name).datum, equals(null));
|
| - }
|
| -
|
| - void test_getRequiredParameter_undefined() {
|
| - String name = 'name';
|
| - Request request = new Request('0', '');
|
| - expect(() => request.getRequiredParameter(name), _throwsRequestFailure);
|
| - }
|
| -
|
| void test_toJson() {
|
| Request request = new Request('one', 'aMethod');
|
| expect(request.toJson(), equals({
|
| @@ -665,7 +385,7 @@ class ResponseTest {
|
| String resultValue = 'value';
|
| Response response = new Response('0');
|
| response.setResult(resultName, resultValue);
|
| - expect(response.getResult(resultName), same(resultValue));
|
| + expect(response.result[resultName], same(resultValue));
|
| expect(response.toJson(), equals({
|
| Response.ID: '0',
|
| Response.RESULT: {
|
|
|