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

Side by Side Diff: pkg/analyzer/test/generated/non_error_resolver_test.dart

Issue 2657663002: Fix tests for resolving documentation with the new analysis driver. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « pkg/analyzer/test/generated/non_error_resolver_driver_test.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 analyzer.test.generated.non_error_resolver_test; 5 library analyzer.test.generated.non_error_resolver_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 1012
1013 test_class_type_alias_documentationComment() async { 1013 test_class_type_alias_documentationComment() async {
1014 Source source = addSource(''' 1014 Source source = addSource('''
1015 /** 1015 /**
1016 * Documentation 1016 * Documentation
1017 */ 1017 */
1018 class C = D with E; 1018 class C = D with E;
1019 1019
1020 class D {} 1020 class D {}
1021 class E {}'''); 1021 class E {}''');
1022 await computeAnalysisResult(source); 1022 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1023 assertNoErrors(source); 1023 assertNoErrors(source);
1024 verify([source]); 1024 verify([source]);
1025 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1025 CompilationUnit unit = analysisResult.unit;
1026 ClassElement classC = 1026 ClassElement classC =
1027 resolutionMap.elementDeclaredByCompilationUnit(unit).getType('C'); 1027 resolutionMap.elementDeclaredByCompilationUnit(unit).getType('C');
1028 expect(classC.documentationComment, isNotNull); 1028 expect(classC.documentationComment, isNotNull);
1029 } 1029 }
1030 1030
1031 test_commentReference_beforeConstructor() async { 1031 test_commentReference_beforeConstructor() async {
1032 String code = r''' 1032 String code = r'''
1033 abstract class A { 1033 abstract class A {
1034 /// [p] 1034 /// [p]
1035 A(int p) {} 1035 A(int p) {}
1036 }'''; 1036 }''';
1037 Source source = addSource(code); 1037 Source source = addSource(code);
1038 await computeAnalysisResult(source); 1038 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1039 assertNoErrors(source); 1039 assertNoErrors(source);
1040 verify([source]); 1040 verify([source]);
1041 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1041 CompilationUnit unit = analysisResult.unit;
1042 { 1042 {
1043 SimpleIdentifier ref = 1043 SimpleIdentifier ref =
1044 EngineTestCase.findSimpleIdentifier(unit, code, "p]"); 1044 EngineTestCase.findSimpleIdentifier(unit, code, "p]");
1045 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1045 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 test_commentReference_beforeEnum() async { 1049 test_commentReference_beforeEnum() async {
1050 String code = r''' 1050 String code = r'''
1051 /// This is the [Samurai] kind. 1051 /// This is the [Samurai] kind.
1052 enum Samurai { 1052 enum Samurai {
1053 /// Use [int]. 1053 /// Use [int].
1054 WITH_SWORD, 1054 WITH_SWORD,
1055 /// Like [WITH_SWORD], but only without one. 1055 /// Like [WITH_SWORD], but only without one.
1056 WITHOUT_SWORD 1056 WITHOUT_SWORD
1057 }'''; 1057 }''';
1058 Source source = addSource(code); 1058 Source source = addSource(code);
1059 await computeAnalysisResult(source); 1059 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1060 assertNoErrors(source); 1060 assertNoErrors(source);
1061 verify([source]); 1061 verify([source]);
1062 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1062 CompilationUnit unit = analysisResult.unit;
1063 { 1063 {
1064 SimpleIdentifier ref = 1064 SimpleIdentifier ref =
1065 EngineTestCase.findSimpleIdentifier(unit, code, 'Samurai]'); 1065 EngineTestCase.findSimpleIdentifier(unit, code, 'Samurai]');
1066 ClassElement refElement = ref.staticElement; 1066 ClassElement refElement = ref.staticElement;
1067 expect(refElement, isNotNull); 1067 expect(refElement, isNotNull);
1068 expect(refElement.name, 'Samurai'); 1068 expect(refElement.name, 'Samurai');
1069 } 1069 }
1070 { 1070 {
1071 SimpleIdentifier ref = 1071 SimpleIdentifier ref =
1072 EngineTestCase.findSimpleIdentifier(unit, code, 'int]'); 1072 EngineTestCase.findSimpleIdentifier(unit, code, 'int]');
1073 ClassElement refElement = ref.staticElement; 1073 ClassElement refElement = ref.staticElement;
1074 expect(refElement, isNotNull); 1074 expect(refElement, isNotNull);
1075 expect(refElement.name, 'int'); 1075 expect(refElement.name, 'int');
1076 } 1076 }
1077 { 1077 {
1078 SimpleIdentifier ref = 1078 SimpleIdentifier ref =
1079 EngineTestCase.findSimpleIdentifier(unit, code, 'WITH_SWORD]'); 1079 EngineTestCase.findSimpleIdentifier(unit, code, 'WITH_SWORD]');
1080 PropertyAccessorElement refElement = ref.staticElement; 1080 PropertyAccessorElement refElement = ref.staticElement;
1081 expect(refElement, isNotNull); 1081 expect(refElement, isNotNull);
1082 expect(refElement.name, 'WITH_SWORD'); 1082 expect(refElement.name, 'WITH_SWORD');
1083 } 1083 }
1084 } 1084 }
1085 1085
1086 test_commentReference_beforeFunction_blockBody() async { 1086 test_commentReference_beforeFunction_blockBody() async {
1087 String code = r''' 1087 String code = r'''
1088 /// [p] 1088 /// [p]
1089 foo(int p) { 1089 foo(int p) {
1090 }'''; 1090 }''';
1091 Source source = addSource(code); 1091 Source source = addSource(code);
1092 await computeAnalysisResult(source); 1092 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1093 assertNoErrors(source); 1093 assertNoErrors(source);
1094 verify([source]); 1094 verify([source]);
1095 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1095 CompilationUnit unit = analysisResult.unit;
1096 SimpleIdentifier ref = 1096 SimpleIdentifier ref =
1097 EngineTestCase.findSimpleIdentifier(unit, code, 'p]'); 1097 EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
1098 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1098 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1099 } 1099 }
1100 1100
1101 test_commentReference_beforeFunction_expressionBody() async { 1101 test_commentReference_beforeFunction_expressionBody() async {
1102 String code = r''' 1102 String code = r'''
1103 /// [p] 1103 /// [p]
1104 foo(int p) => null;'''; 1104 foo(int p) => null;''';
1105 Source source = addSource(code); 1105 Source source = addSource(code);
1106 await computeAnalysisResult(source); 1106 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1107 assertNoErrors(source); 1107 assertNoErrors(source);
1108 verify([source]); 1108 verify([source]);
1109 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1109 CompilationUnit unit = analysisResult.unit;
1110 SimpleIdentifier ref = 1110 SimpleIdentifier ref =
1111 EngineTestCase.findSimpleIdentifier(unit, code, 'p]'); 1111 EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
1112 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1112 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1113 } 1113 }
1114 1114
1115 test_commentReference_beforeFunctionTypeAlias() async { 1115 test_commentReference_beforeFunctionTypeAlias() async {
1116 String code = r''' 1116 String code = r'''
1117 /// [p] 1117 /// [p]
1118 typedef Foo(int p); 1118 typedef Foo(int p);
1119 '''; 1119 ''';
1120 Source source = addSource(code); 1120 Source source = addSource(code);
1121 await computeAnalysisResult(source); 1121 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1122 assertNoErrors(source); 1122 assertNoErrors(source);
1123 verify([source]); 1123 verify([source]);
1124 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1124 CompilationUnit unit = analysisResult.unit;
1125 SimpleIdentifier ref = 1125 SimpleIdentifier ref =
1126 EngineTestCase.findSimpleIdentifier(unit, code, 'p]'); 1126 EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
1127 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1127 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1128 } 1128 }
1129 1129
1130 test_commentReference_beforeGetter() async { 1130 test_commentReference_beforeGetter() async {
1131 String code = r''' 1131 String code = r'''
1132 abstract class A { 1132 abstract class A {
1133 /// [int] 1133 /// [int]
1134 get g => null; 1134 get g => null;
1135 }'''; 1135 }''';
1136 Source source = addSource(code); 1136 Source source = addSource(code);
1137 await computeAnalysisResult(source); 1137 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1138 assertNoErrors(source); 1138 assertNoErrors(source);
1139 verify([source]); 1139 verify([source]);
1140 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1140 CompilationUnit unit = analysisResult.unit;
1141 { 1141 {
1142 SimpleIdentifier ref = 1142 SimpleIdentifier ref =
1143 EngineTestCase.findSimpleIdentifier(unit, code, 'int]'); 1143 EngineTestCase.findSimpleIdentifier(unit, code, 'int]');
1144 expect(ref.staticElement, isNotNull); 1144 expect(ref.staticElement, isNotNull);
1145 } 1145 }
1146 } 1146 }
1147 1147
1148 test_commentReference_beforeMethod() async { 1148 test_commentReference_beforeMethod() async {
1149 String code = r''' 1149 String code = r'''
1150 abstract class A { 1150 abstract class A {
1151 /// [p1] 1151 /// [p1]
1152 ma(int p1) {} 1152 ma(int p1) {}
1153 /// [p2] 1153 /// [p2]
1154 mb(int p2); 1154 mb(int p2);
1155 /// [p3] and [p4] 1155 /// [p3] and [p4]
1156 mc(int p3, p4()); 1156 mc(int p3, p4());
1157 /// [p5] 1157 /// [p5]
1158 md(int p5, {int p6}); 1158 md(int p5, {int p6});
1159 }'''; 1159 }''';
1160 Source source = addSource(code); 1160 Source source = addSource(code);
1161 await computeAnalysisResult(source); 1161 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1162 assertNoErrors(source); 1162 assertNoErrors(source);
1163 verify([source]); 1163 verify([source]);
1164 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1164 CompilationUnit unit = analysisResult.unit;
1165 assertIsParameter(String search) { 1165 assertIsParameter(String search) {
1166 SimpleIdentifier ref = 1166 SimpleIdentifier ref =
1167 EngineTestCase.findSimpleIdentifier(unit, code, search); 1167 EngineTestCase.findSimpleIdentifier(unit, code, search);
1168 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1168 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1169 } 1169 }
1170 1170
1171 assertIsParameter('p1'); 1171 assertIsParameter('p1');
1172 assertIsParameter('p2'); 1172 assertIsParameter('p2');
1173 assertIsParameter('p3'); 1173 assertIsParameter('p3');
1174 assertIsParameter('p4'); 1174 assertIsParameter('p4');
1175 assertIsParameter('p5'); 1175 assertIsParameter('p5');
1176 assertIsParameter('p6'); 1176 assertIsParameter('p6');
1177 } 1177 }
1178 1178
1179 test_commentReference_class() async { 1179 test_commentReference_class() async {
1180 String code = r''' 1180 String code = r'''
1181 /// [foo] 1181 /// [foo]
1182 class A { 1182 class A {
1183 foo() {} 1183 foo() {}
1184 }'''; 1184 }''';
1185 Source source = addSource(code); 1185 Source source = addSource(code);
1186 await computeAnalysisResult(source); 1186 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1187 assertNoErrors(source); 1187 assertNoErrors(source);
1188 verify([source]); 1188 verify([source]);
1189 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1189 CompilationUnit unit = analysisResult.unit;
1190 SimpleIdentifier ref = 1190 SimpleIdentifier ref =
1191 EngineTestCase.findSimpleIdentifier(unit, code, 'foo]'); 1191 EngineTestCase.findSimpleIdentifier(unit, code, 'foo]');
1192 expect(ref.staticElement, new isInstanceOf<MethodElement>()); 1192 expect(ref.staticElement, new isInstanceOf<MethodElement>());
1193 } 1193 }
1194 1194
1195 test_commentReference_setter() async { 1195 test_commentReference_setter() async {
1196 String code = r''' 1196 String code = r'''
1197 class A { 1197 class A {
1198 /// [x] in A 1198 /// [x] in A
1199 mA() {} 1199 mA() {}
1200 set x(value) {} 1200 set x(value) {}
1201 } 1201 }
1202 class B extends A { 1202 class B extends A {
1203 /// [x] in B 1203 /// [x] in B
1204 mB() {} 1204 mB() {}
1205 } 1205 }
1206 '''; 1206 ''';
1207 Source source = addSource(code); 1207 Source source = addSource(code);
1208 await computeAnalysisResult(source); 1208 TestAnalysisResult analysisResult = await computeAnalysisResult(source);
1209 assertNoErrors(source); 1209 assertNoErrors(source);
1210 verify([source]); 1210 verify([source]);
1211 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1211 CompilationUnit unit = analysisResult.unit;
1212 { 1212 {
1213 SimpleIdentifier ref = 1213 SimpleIdentifier ref =
1214 EngineTestCase.findSimpleIdentifier(unit, code, "x] in A"); 1214 EngineTestCase.findSimpleIdentifier(unit, code, "x] in A");
1215 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>()); 1215 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>());
1216 } 1216 }
1217 { 1217 {
1218 SimpleIdentifier ref = 1218 SimpleIdentifier ref =
1219 EngineTestCase.findSimpleIdentifier(unit, code, 'x] in B'); 1219 EngineTestCase.findSimpleIdentifier(unit, code, 'x] in B');
1220 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>()); 1220 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>());
1221 } 1221 }
(...skipping 5040 matching lines...) Expand 10 before | Expand all | Expand 10 after
6262 } 6262 }
6263 6263
6264 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { 6264 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async {
6265 await _check_wrongNumberOfParametersForOperator(name, "a"); 6265 await _check_wrongNumberOfParametersForOperator(name, "a");
6266 } 6266 }
6267 6267
6268 Future<CompilationUnit> _getResolvedLibraryUnit(Source source) async { 6268 Future<CompilationUnit> _getResolvedLibraryUnit(Source source) async {
6269 return analysisContext.getResolvedCompilationUnit2(source, source); 6269 return analysisContext.getResolvedCompilationUnit2(source, source);
6270 } 6270 }
6271 } 6271 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/non_error_resolver_driver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698