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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_test.dart

Issue 1528983004: Add support for the "external" keyword to summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.src.summary.summary_test; 5 library analyzer.test.src.summary.summary_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/java_engine_io.dart'; 9 import 'package:analyzer/src/generated/java_engine_io.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 expect(cls.typeParameters, hasLength(1)); 780 expect(cls.typeParameters, hasLength(1));
781 expect(cls.typeParameters[0].name, 'T'); 781 expect(cls.typeParameters[0].name, 'T');
782 expect(cls.typeParameters[0].bound, isNull); 782 expect(cls.typeParameters[0].bound, isNull);
783 } 783 }
784 784
785 test_constructor() { 785 test_constructor() {
786 UnlinkedExecutable executable = findExecutable('', 786 UnlinkedExecutable executable = findExecutable('',
787 executables: serializeClassText('class C { C(); }').executables); 787 executables: serializeClassText('class C { C(); }').executables);
788 expect(executable.kind, UnlinkedExecutableKind.constructor); 788 expect(executable.kind, UnlinkedExecutableKind.constructor);
789 expect(executable.hasImplicitReturnType, isFalse); 789 expect(executable.hasImplicitReturnType, isFalse);
790 expect(executable.isExternal, isFalse);
790 } 791 }
791 792
792 test_constructor_anonymous() { 793 test_constructor_anonymous() {
793 UnlinkedExecutable executable = findExecutable('', 794 UnlinkedExecutable executable = findExecutable('',
794 executables: serializeClassText('class C { C(); }').executables); 795 executables: serializeClassText('class C { C(); }').executables);
795 expect(executable.name, isEmpty); 796 expect(executable.name, isEmpty);
796 } 797 }
797 798
798 test_constructor_const() { 799 test_constructor_const() {
799 UnlinkedExecutable executable = findExecutable('', 800 UnlinkedExecutable executable = findExecutable('',
800 executables: serializeClassText('class C { const C(); }').executables); 801 executables: serializeClassText('class C { const C(); }').executables);
801 expect(executable.isConst, isTrue); 802 expect(executable.isConst, isTrue);
803 expect(executable.isExternal, isFalse);
804 }
805
806 test_constructor_const_external() {
807 UnlinkedExecutable executable = findExecutable('',
808 executables:
809 serializeClassText('class C { external const C(); }').executables);
810 expect(executable.isConst, isTrue);
811 expect(executable.isExternal, isTrue);
812 }
813
814 test_constructor_external() {
815 UnlinkedExecutable executable = findExecutable('',
816 executables:
817 serializeClassText('class C { external C(); }').executables);
818 expect(executable.isExternal, isTrue);
802 } 819 }
803 820
804 test_constructor_factory() { 821 test_constructor_factory() {
805 UnlinkedExecutable executable = findExecutable('', 822 UnlinkedExecutable executable = findExecutable('',
806 executables: 823 executables:
807 serializeClassText('class C { factory C() => null; }').executables); 824 serializeClassText('class C { factory C() => null; }').executables);
808 expect(executable.isFactory, isTrue); 825 expect(executable.isFactory, isTrue);
809 } 826 }
810 827
811 test_constructor_implicit() { 828 test_constructor_implicit() {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 UnlinkedExecutable executable = 1126 UnlinkedExecutable executable =
1110 serializeClassText('abstract class C { f() {} }').executables[0]; 1127 serializeClassText('abstract class C { f() {} }').executables[0];
1111 expect(executable.isAbstract, isFalse); 1128 expect(executable.isAbstract, isFalse);
1112 } 1129 }
1113 1130
1114 test_executable_function() { 1131 test_executable_function() {
1115 UnlinkedExecutable executable = serializeExecutableText('f() {}'); 1132 UnlinkedExecutable executable = serializeExecutableText('f() {}');
1116 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); 1133 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1117 expect(executable.hasImplicitReturnType, isTrue); 1134 expect(executable.hasImplicitReturnType, isTrue);
1118 checkDynamicTypeRef(executable.returnType); 1135 checkDynamicTypeRef(executable.returnType);
1136 expect(executable.isExternal, isFalse);
1119 } 1137 }
1120 1138
1121 test_executable_function_explicit_return() { 1139 test_executable_function_explicit_return() {
1122 UnlinkedExecutable executable = 1140 UnlinkedExecutable executable =
1123 serializeExecutableText('dynamic f() => null;'); 1141 serializeExecutableText('dynamic f() => null;');
1124 expect(executable.hasImplicitReturnType, isFalse); 1142 expect(executable.hasImplicitReturnType, isFalse);
1125 checkDynamicTypeRef(executable.returnType); 1143 checkDynamicTypeRef(executable.returnType);
1126 } 1144 }
1127 1145
1146 test_executable_function_external() {
1147 UnlinkedExecutable executable = serializeExecutableText('external f();');
1148 expect(executable.isExternal, isTrue);
1149 }
1150
1128 test_executable_getter() { 1151 test_executable_getter() {
1129 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); 1152 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;');
1130 expect(executable.kind, UnlinkedExecutableKind.getter); 1153 expect(executable.kind, UnlinkedExecutableKind.getter);
1131 expect(executable.hasImplicitReturnType, isFalse); 1154 expect(executable.hasImplicitReturnType, isFalse);
1155 expect(executable.isExternal, isFalse);
1132 expect(findVariable('f'), isNull); 1156 expect(findVariable('f'), isNull);
1133 expect(findExecutable('f='), isNull); 1157 expect(findExecutable('f='), isNull);
1134 } 1158 }
1135 1159
1160 test_executable_getter_external() {
1161 UnlinkedExecutable executable =
1162 serializeExecutableText('external int get f;');
1163 expect(executable.isExternal, isTrue);
1164 }
1165
1136 test_executable_getter_type() { 1166 test_executable_getter_type() {
1137 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); 1167 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;');
1138 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); 1168 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int');
1139 expect(executable.parameters, isEmpty); 1169 expect(executable.parameters, isEmpty);
1140 } 1170 }
1141 1171
1142 test_executable_getter_type_implicit() { 1172 test_executable_getter_type_implicit() {
1143 UnlinkedExecutable executable = serializeExecutableText('get f => 1;'); 1173 UnlinkedExecutable executable = serializeExecutableText('get f => 1;');
1144 checkDynamicTypeRef(executable.returnType); 1174 checkDynamicTypeRef(executable.returnType);
1145 expect(executable.hasImplicitReturnType, isTrue); 1175 expect(executable.hasImplicitReturnType, isTrue);
1146 expect(executable.parameters, isEmpty); 1176 expect(executable.parameters, isEmpty);
1147 } 1177 }
1148 1178
1149 test_executable_member_function() { 1179 test_executable_member_function() {
1150 UnlinkedExecutable executable = findExecutable('f', 1180 UnlinkedExecutable executable = findExecutable('f',
1151 executables: serializeClassText('class C { f() {} }').executables); 1181 executables: serializeClassText('class C { f() {} }').executables);
1152 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); 1182 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1153 expect(executable.hasImplicitReturnType, isTrue); 1183 expect(executable.hasImplicitReturnType, isTrue);
1184 expect(executable.isExternal, isFalse);
1154 } 1185 }
1155 1186
1156 test_executable_member_function_explicit_return() { 1187 test_executable_member_function_explicit_return() {
1157 UnlinkedExecutable executable = findExecutable('f', 1188 UnlinkedExecutable executable = findExecutable('f',
1158 executables: 1189 executables:
1159 serializeClassText('class C { dynamic f() => null; }').executables); 1190 serializeClassText('class C { dynamic f() => null; }').executables);
1160 expect(executable.hasImplicitReturnType, isFalse); 1191 expect(executable.hasImplicitReturnType, isFalse);
1161 } 1192 }
1162 1193
1194 test_executable_member_function_external() {
1195 UnlinkedExecutable executable = findExecutable('f',
1196 executables:
1197 serializeClassText('class C { external f(); }').executables);
1198 expect(executable.isExternal, isTrue);
1199 }
1200
1163 test_executable_member_getter() { 1201 test_executable_member_getter() {
1164 UnlinkedClass cls = serializeClassText('class C { int get f => 1; }'); 1202 UnlinkedClass cls = serializeClassText('class C { int get f => 1; }');
1165 UnlinkedExecutable executable = 1203 UnlinkedExecutable executable =
1166 findExecutable('f', executables: cls.executables, failIfAbsent: true); 1204 findExecutable('f', executables: cls.executables, failIfAbsent: true);
1167 expect(executable.kind, UnlinkedExecutableKind.getter); 1205 expect(executable.kind, UnlinkedExecutableKind.getter);
1168 expect(executable.hasImplicitReturnType, isFalse); 1206 expect(executable.hasImplicitReturnType, isFalse);
1207 expect(executable.isExternal, isFalse);
1169 expect(findVariable('f', variables: cls.fields), isNull); 1208 expect(findVariable('f', variables: cls.fields), isNull);
1170 expect(findExecutable('f=', executables: cls.executables), isNull); 1209 expect(findExecutable('f=', executables: cls.executables), isNull);
1171 } 1210 }
1172 1211
1212 test_executable_member_getter_external() {
1213 UnlinkedClass cls = serializeClassText('class C { external int get f; }');
1214 UnlinkedExecutable executable =
1215 findExecutable('f', executables: cls.executables, failIfAbsent: true);
1216 expect(executable.isExternal, isTrue);
1217 }
1218
1173 test_executable_member_setter() { 1219 test_executable_member_setter() {
1174 UnlinkedClass cls = serializeClassText('class C { void set f(value) {} }'); 1220 UnlinkedClass cls = serializeClassText('class C { void set f(value) {} }');
1175 UnlinkedExecutable executable = 1221 UnlinkedExecutable executable =
1176 findExecutable('f=', executables: cls.executables, failIfAbsent: true); 1222 findExecutable('f=', executables: cls.executables, failIfAbsent: true);
1177 expect(executable.kind, UnlinkedExecutableKind.setter); 1223 expect(executable.kind, UnlinkedExecutableKind.setter);
1178 // For setters, hasImplicitReturnType is always false. 1224 // For setters, hasImplicitReturnType is always false.
1179 expect(executable.hasImplicitReturnType, isFalse); 1225 expect(executable.hasImplicitReturnType, isFalse);
1226 expect(executable.isExternal, isFalse);
1180 expect(findVariable('f', variables: cls.fields), isNull); 1227 expect(findVariable('f', variables: cls.fields), isNull);
1181 expect(findExecutable('f', executables: cls.executables), isNull); 1228 expect(findExecutable('f', executables: cls.executables), isNull);
1182 } 1229 }
1183 1230
1231 test_executable_member_setter_external() {
1232 UnlinkedClass cls =
1233 serializeClassText('class C { external void set f(value); }');
1234 UnlinkedExecutable executable =
1235 findExecutable('f=', executables: cls.executables, failIfAbsent: true);
1236 expect(executable.isExternal, isTrue);
1237 }
1238
1184 test_executable_member_setter_implicit_return() { 1239 test_executable_member_setter_implicit_return() {
1185 UnlinkedClass cls = serializeClassText('class C { set f(value) {} }'); 1240 UnlinkedClass cls = serializeClassText('class C { set f(value) {} }');
1186 UnlinkedExecutable executable = 1241 UnlinkedExecutable executable =
1187 findExecutable('f=', executables: cls.executables, failIfAbsent: true); 1242 findExecutable('f=', executables: cls.executables, failIfAbsent: true);
1188 expect(executable.hasImplicitReturnType, isFalse); 1243 expect(executable.hasImplicitReturnType, isFalse);
1189 checkDynamicTypeRef(executable.returnType); 1244 checkDynamicTypeRef(executable.returnType);
1190 } 1245 }
1191 1246
1192 test_executable_name() { 1247 test_executable_name() {
1193 UnlinkedExecutable executable = serializeExecutableText('f() {}'); 1248 UnlinkedExecutable executable = serializeExecutableText('f() {}');
(...skipping 13 matching lines...) Expand all
1207 serializeClassText('class C { f() {} }').executables[0]; 1262 serializeClassText('class C { f() {} }').executables[0];
1208 expect(executable.isStatic, isFalse); 1263 expect(executable.isStatic, isFalse);
1209 } 1264 }
1210 1265
1211 test_executable_non_static_top_level() { 1266 test_executable_non_static_top_level() {
1212 // Top level executables are considered non-static. 1267 // Top level executables are considered non-static.
1213 UnlinkedExecutable executable = serializeExecutableText('f() {}'); 1268 UnlinkedExecutable executable = serializeExecutableText('f() {}');
1214 expect(executable.isStatic, isFalse); 1269 expect(executable.isStatic, isFalse);
1215 } 1270 }
1216 1271
1272 test_executable_operator() {
1273 UnlinkedExecutable executable =
1274 serializeClassText('class C { C operator+(C c) => null; }').executables[
1275 0];
1276 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1277 expect(executable.name, '+');
1278 expect(executable.hasImplicitReturnType, false);
1279 expect(executable.isAbstract, false);
1280 expect(executable.isConst, false);
1281 expect(executable.isFactory, false);
1282 expect(executable.isStatic, false);
1283 expect(executable.parameters, hasLength(1));
1284 checkTypeRef(executable.returnType, null, null, 'C');
1285 expect(executable.typeParameters, isEmpty);
1286 expect(executable.isExternal, false);
1287 }
1288
1289 test_executable_operator_external() {
1290 UnlinkedExecutable executable =
1291 serializeClassText('class C { external C operator+(C c); }')
1292 .executables[0];
1293 expect(executable.isExternal, true);
1294 }
1295
1217 test_executable_operator_index() { 1296 test_executable_operator_index() {
1218 UnlinkedExecutable executable = 1297 UnlinkedExecutable executable =
1219 serializeClassText('class C { bool operator[](int i) => null; }') 1298 serializeClassText('class C { bool operator[](int i) => null; }')
1220 .executables[0]; 1299 .executables[0];
1221 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); 1300 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1222 expect(executable.name, '[]'); 1301 expect(executable.name, '[]');
1223 expect(executable.hasImplicitReturnType, false); 1302 expect(executable.hasImplicitReturnType, false);
1224 expect(executable.isAbstract, false); 1303 expect(executable.isAbstract, false);
1225 expect(executable.isConst, false); 1304 expect(executable.isConst, false);
1226 expect(executable.isFactory, false); 1305 expect(executable.isFactory, false);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 test_executable_return_type_void() { 1443 test_executable_return_type_void() {
1365 UnlinkedExecutable executable = serializeExecutableText('void f() {}'); 1444 UnlinkedExecutable executable = serializeExecutableText('void f() {}');
1366 expect(executable.returnType, isNull); 1445 expect(executable.returnType, isNull);
1367 } 1446 }
1368 1447
1369 test_executable_setter() { 1448 test_executable_setter() {
1370 UnlinkedExecutable executable = 1449 UnlinkedExecutable executable =
1371 serializeExecutableText('void set f(value) {}', 'f='); 1450 serializeExecutableText('void set f(value) {}', 'f=');
1372 expect(executable.kind, UnlinkedExecutableKind.setter); 1451 expect(executable.kind, UnlinkedExecutableKind.setter);
1373 expect(executable.hasImplicitReturnType, isFalse); 1452 expect(executable.hasImplicitReturnType, isFalse);
1453 expect(executable.isExternal, isFalse);
1374 expect(findVariable('f'), isNull); 1454 expect(findVariable('f'), isNull);
1375 expect(findExecutable('f'), isNull); 1455 expect(findExecutable('f'), isNull);
1376 } 1456 }
1377 1457
1458 test_executable_setter_external() {
1459 UnlinkedExecutable executable =
1460 serializeExecutableText('external void set f(value);', 'f=');
1461 expect(executable.isExternal, isTrue);
1462 }
1463
1378 test_executable_setter_implicit_return() { 1464 test_executable_setter_implicit_return() {
1379 UnlinkedExecutable executable = 1465 UnlinkedExecutable executable =
1380 serializeExecutableText('set f(value) {}', 'f='); 1466 serializeExecutableText('set f(value) {}', 'f=');
1381 // For setters, hasImplicitReturnType is always false. 1467 // For setters, hasImplicitReturnType is always false.
1382 expect(executable.hasImplicitReturnType, isFalse); 1468 expect(executable.hasImplicitReturnType, isFalse);
1383 checkDynamicTypeRef(executable.returnType); 1469 checkDynamicTypeRef(executable.returnType);
1384 } 1470 }
1385 1471
1386 test_executable_setter_type() { 1472 test_executable_setter_type() {
1387 UnlinkedExecutable executable = 1473 UnlinkedExecutable executable =
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 serializeClassText('class C { static int i; }').fields[0]; 2104 serializeClassText('class C { static int i; }').fields[0];
2019 expect(variable.isStatic, isTrue); 2105 expect(variable.isStatic, isTrue);
2020 } 2106 }
2021 2107
2022 test_variable_type() { 2108 test_variable_type() {
2023 UnlinkedVariable variable = 2109 UnlinkedVariable variable =
2024 serializeVariableText('int i;', variableName: 'i'); 2110 serializeVariableText('int i;', variableName: 'i');
2025 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 2111 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
2026 } 2112 }
2027 } 2113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698