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

Unified Diff: pkg/analysis_server/test/protocol_server_test.dart

Issue 725143004: Format and sort analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/test/operation/test_all.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/protocol_server_test.dart
diff --git a/pkg/analysis_server/test/protocol_server_test.dart b/pkg/analysis_server/test/protocol_server_test.dart
index ca6198de47655e9687751a2bafbb41ca7baed8b1..7b47452e8f738bee02332f1d40d99cc7097ec7dd 100644
--- a/pkg/analysis_server/test/protocol_server_test.dart
+++ b/pkg/analysis_server/test/protocol_server_test.dart
@@ -274,6 +274,18 @@ class A {
expect(element.flags, Element.FLAG_CONST);
}
+ void test_fromElement_dynamic() {
+ var engineElement = engine.DynamicElementImpl.instance;
+ // create notification Element
+ Element element = newElement_fromEngine(engineElement);
+ expect(element.kind, ElementKind.UNKNOWN);
+ expect(element.name, 'dynamic');
+ expect(element.location, isNull);
+ expect(element.parameters, isNull);
+ expect(element.returnType, isNull);
+ expect(element.flags, 0);
+ }
+
void test_fromElement_FIELD() {
engine.Source source = addSource('/test.dart', '''
class A {
@@ -401,65 +413,8 @@ class A {
expect(element.returnType, isNull);
expect(element.flags, 0);
}
-
- void test_fromElement_dynamic() {
- var engineElement = engine.DynamicElementImpl.instance;
- // create notification Element
- Element element = newElement_fromEngine(engineElement);
- expect(element.kind, ElementKind.UNKNOWN);
- expect(element.name, 'dynamic');
- expect(element.location, isNull);
- expect(element.parameters, isNull);
- expect(element.returnType, isNull);
- expect(element.flags, 0);
- }
-}
-
-/**
- * Helper class for testing the correspondence between an analysis engine enum
- * and an analysis server API enum.
- */
-class EnumTester<EngineEnum, ApiEnum extends Enum> {
- /**
- * Test that the function [convert] properly converts all possible values of
- * [EngineEnum] to an [ApiEnum] with the same name, with the exceptions noted
- * in [exceptions]. For each key in [exceptions], if the corresponding value
- * is null, then we check that converting the given key results in an error.
- * If the corresponding value is an [ApiEnum], then we check that converting
- * the given key results in the given value.
- */
- void run(ApiEnum convert(EngineEnum value), {Map<EngineEnum,
- ApiEnum> exceptions: const {}}) {
- ClassMirror engineClass = reflectClass(EngineEnum);
- engineClass.staticMembers.forEach((Symbol symbol, MethodMirror method) {
- if (symbol == #values) {
- return;
- }
- if (!method.isGetter) {
- return;
- }
- String enumName = MirrorSystem.getName(symbol);
- EngineEnum engineValue = engineClass.getField(symbol).reflectee;
- expect(engineValue, new isInstanceOf<EngineEnum>());
- if (exceptions.containsKey(engineValue)) {
- ApiEnum expectedResult = exceptions[engineValue];
- if (expectedResult == null) {
- expect(() {
- convert(engineValue);
- }, throws);
- } else {
- ApiEnum apiValue = convert(engineValue);
- expect(apiValue, equals(expectedResult));
- }
- } else {
- ApiEnum apiValue = convert(engineValue);
- expect(apiValue.name, equals(enumName));
- }
- });
- }
}
-
@ReflectiveTestCase()
class EnumTest {
void test_AnalysisErrorSeverity() {
@@ -511,9 +466,54 @@ class EnumTest {
new EnumTester<MatchKind, SearchResultKind>().run(
newSearchResultKind_fromEngine,
exceptions: {
- // TODO(paulberry): do any of the exceptions below constitute bugs?
- MatchKind.ANGULAR_REFERENCE: SearchResultKind.UNKNOWN,
- MatchKind.ANGULAR_CLOSING_TAG_REFERENCE: SearchResultKind.UNKNOWN
- });
+ // TODO(paulberry): do any of the exceptions below constitute bugs?
+ MatchKind.ANGULAR_REFERENCE: SearchResultKind.UNKNOWN,
+ MatchKind.ANGULAR_CLOSING_TAG_REFERENCE: SearchResultKind.UNKNOWN
+ });
+ }
+}
+
+
+/**
+ * Helper class for testing the correspondence between an analysis engine enum
+ * and an analysis server API enum.
+ */
+class EnumTester<EngineEnum, ApiEnum extends Enum> {
+ /**
+ * Test that the function [convert] properly converts all possible values of
+ * [EngineEnum] to an [ApiEnum] with the same name, with the exceptions noted
+ * in [exceptions]. For each key in [exceptions], if the corresponding value
+ * is null, then we check that converting the given key results in an error.
+ * If the corresponding value is an [ApiEnum], then we check that converting
+ * the given key results in the given value.
+ */
+ void run(ApiEnum convert(EngineEnum value), {Map<EngineEnum,
+ ApiEnum> exceptions: const {}}) {
+ ClassMirror engineClass = reflectClass(EngineEnum);
+ engineClass.staticMembers.forEach((Symbol symbol, MethodMirror method) {
+ if (symbol == #values) {
+ return;
+ }
+ if (!method.isGetter) {
+ return;
+ }
+ String enumName = MirrorSystem.getName(symbol);
+ EngineEnum engineValue = engineClass.getField(symbol).reflectee;
+ expect(engineValue, new isInstanceOf<EngineEnum>());
+ if (exceptions.containsKey(engineValue)) {
+ ApiEnum expectedResult = exceptions[engineValue];
+ if (expectedResult == null) {
+ expect(() {
+ convert(engineValue);
+ }, throws);
+ } else {
+ ApiEnum apiValue = convert(engineValue);
+ expect(apiValue, equals(expectedResult));
+ }
+ } else {
+ ApiEnum apiValue = convert(engineValue);
+ expect(apiValue.name, equals(enumName));
+ }
+ });
}
}
« no previous file with comments | « pkg/analysis_server/test/operation/test_all.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698