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

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

Issue 2342893002: Issue 27044. Summarize configurations of imports and exports, AST based. (Closed)
Patch Set: No equality test means '== true'. Created 4 years, 3 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/lib/src/summary/summarize_ast.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) 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_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/error/listener.dart'; 10 import 'package:analyzer/error/listener.dart';
(...skipping 6039 matching lines...) Expand 10 before | Expand all | Expand 10 after
6050 6050
6051 test_export_class_alias() { 6051 test_export_class_alias() {
6052 addNamedSource( 6052 addNamedSource(
6053 '/a.dart', 'class C extends _D with _E {} class _D {} class _E {}'); 6053 '/a.dart', 'class C extends _D with _E {} class _D {} class _E {}');
6054 serializeLibraryText('export "a.dart";'); 6054 serializeLibraryText('export "a.dart";');
6055 expect(linked.exportNames, hasLength(1)); 6055 expect(linked.exportNames, hasLength(1));
6056 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C', 6056 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C',
6057 ReferenceKind.classOrEnum); 6057 ReferenceKind.classOrEnum);
6058 } 6058 }
6059 6059
6060 test_export_configurations() {
6061 if (!checkAstDerivedData) {
6062 // Element model does not provide access to configurations.
6063 return;
6064 }
6065 addNamedSource('/foo.dart', 'bar() {}');
6066 addNamedSource('/foo_io.dart', 'bar() {}');
6067 addNamedSource('/foo_html.dart', 'bar() {}');
6068 String libraryText = r'''
6069 export 'foo.dart'
6070 if (dart.library.io) 'foo_io.dart'
6071 if (dart.flavor == 'html') 'foo_html.dart';
6072 ''';
6073 serializeLibraryText(libraryText);
6074 UnlinkedExportPublic exp = unlinkedUnits[0].publicNamespace.exports[0];
6075 expect(exp.configurations, hasLength(2));
6076 {
6077 UnlinkedConfiguration configuration = exp.configurations[0];
6078 expect(configuration.name, 'dart.library.io');
6079 expect(configuration.value, 'true');
6080 expect(configuration.uri, 'foo_io.dart');
6081 }
6082 {
6083 UnlinkedConfiguration configuration = exp.configurations[1];
6084 expect(configuration.name, 'dart.flavor');
6085 expect(configuration.value, 'html');
6086 expect(configuration.uri, 'foo_html.dart');
6087 }
6088 }
6089
6060 test_export_dependency() { 6090 test_export_dependency() {
6061 serializeLibraryText('export "dart:async";'); 6091 serializeLibraryText('export "dart:async";');
6062 expect(unlinkedUnits[0].exports, hasLength(1)); 6092 expect(unlinkedUnits[0].exports, hasLength(1));
6063 checkDependency(linked.exportDependencies[0], 'dart:async', 'dart:async'); 6093 checkDependency(linked.exportDependencies[0], 'dart:async', 'dart:async');
6064 } 6094 }
6065 6095
6066 test_export_enum() { 6096 test_export_enum() {
6067 addNamedSource('/a.dart', 'enum E { v }'); 6097 addNamedSource('/a.dart', 'enum E { v }');
6068 serializeLibraryText('export "a.dart";'); 6098 serializeLibraryText('export "a.dart";');
6069 expect(linked.exportNames, hasLength(1)); 6099 expect(linked.exportNames, hasLength(1));
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6253 expect(linked.exportNames, hasLength(1)); 6283 expect(linked.exportNames, hasLength(1));
6254 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'F', 6284 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'F',
6255 ReferenceKind.typedef); 6285 ReferenceKind.typedef);
6256 } 6286 }
6257 6287
6258 test_export_uri() { 6288 test_export_uri() {
6259 addNamedSource('/a.dart', 'library my.lib;'); 6289 addNamedSource('/a.dart', 'library my.lib;');
6260 String uriString = '"a.dart"'; 6290 String uriString = '"a.dart"';
6261 String libraryText = 'export $uriString;'; 6291 String libraryText = 'export $uriString;';
6262 serializeLibraryText(libraryText); 6292 serializeLibraryText(libraryText);
6263 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); 6293 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports;
6264 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'a.dart'); 6294 expect(unlinkedExports, hasLength(1));
6295 expect(unlinkedExports[0].uri, 'a.dart');
6296 expect(unlinkedExports[0].configurations, isEmpty);
6265 } 6297 }
6266 6298
6267 test_export_variable() { 6299 test_export_variable() {
6268 addNamedSource('/a.dart', 'var v;'); 6300 addNamedSource('/a.dart', 'var v;');
6269 serializeLibraryText('export "a.dart";'); 6301 serializeLibraryText('export "a.dart";');
6270 expect(linked.exportNames, hasLength(2)); 6302 expect(linked.exportNames, hasLength(2));
6271 LinkedExportName getter = 6303 LinkedExportName getter =
6272 linked.exportNames.firstWhere((e) => e.name == 'v'); 6304 linked.exportNames.firstWhere((e) => e.name == 'v');
6273 expect(getter, isNotNull); 6305 expect(getter, isNotNull);
6274 checkExportName(getter, absUri('/a.dart'), 'a.dart', 'v', 6306 checkExportName(getter, absUri('/a.dart'), 'a.dart', 'v',
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
7871 // The dependency on b.dart is implicit, so it should be placed at the end 7903 // The dependency on b.dart is implicit, so it should be placed at the end
7872 // of the dependency list, after a.dart, even though the code that refers 7904 // of the dependency list, after a.dart, even though the code that refers
7873 // to b.dart comes before the code that refers to a.dart. 7905 // to b.dart comes before the code that refers to a.dart.
7874 int aDep = 7906 int aDep =
7875 checkHasDependency(absUri('/a.dart'), 'a.dart', fullyLinked: false); 7907 checkHasDependency(absUri('/a.dart'), 'a.dart', fullyLinked: false);
7876 int bDep = 7908 int bDep =
7877 checkHasDependency(absUri('/b.dart'), 'b.dart', fullyLinked: true); 7909 checkHasDependency(absUri('/b.dart'), 'b.dart', fullyLinked: true);
7878 expect(aDep, lessThan(bDep)); 7910 expect(aDep, lessThan(bDep));
7879 } 7911 }
7880 7912
7913 test_import_configurations() {
7914 if (!checkAstDerivedData) {
7915 // Element model does not provide access to configurations.
7916 return;
7917 }
7918 addNamedSource('/foo.dart', 'bar() {}');
7919 addNamedSource('/foo_io.dart', 'bar() {}');
7920 addNamedSource('/foo_html.dart', 'bar() {}');
7921 String libraryText = r'''
7922 import 'foo.dart'
7923 if (dart.library.io) 'foo_io.dart'
7924 if (dart.flavor == 'html') 'foo_html.dart';
7925 ''';
7926 serializeLibraryText(libraryText);
7927 UnlinkedImport imp = unlinkedUnits[0].imports[0];
7928 expect(imp.configurations, hasLength(2));
7929 {
7930 UnlinkedConfiguration configuration = imp.configurations[0];
7931 expect(configuration.name, 'dart.library.io');
7932 expect(configuration.value, 'true');
7933 expect(configuration.uri, 'foo_io.dart');
7934 }
7935 {
7936 UnlinkedConfiguration configuration = imp.configurations[1];
7937 expect(configuration.name, 'dart.flavor');
7938 expect(configuration.value, 'html');
7939 expect(configuration.uri, 'foo_html.dart');
7940 }
7941 }
7942
7881 test_import_deferred() { 7943 test_import_deferred() {
7882 serializeLibraryText( 7944 serializeLibraryText(
7883 'import "dart:async" deferred as a; main() { print(a.Future); }'); 7945 'import "dart:async" deferred as a; main() { print(a.Future); }');
7884 expect(unlinkedUnits[0].imports[0].isDeferred, isTrue); 7946 expect(unlinkedUnits[0].imports[0].isDeferred, isTrue);
7885 } 7947 }
7886 7948
7887 test_import_dependency() { 7949 test_import_dependency() {
7888 serializeLibraryText('import "dart:async"; Future x;'); 7950 serializeLibraryText('import "dart:async"; Future x;');
7889 // Second import is the implicit import of dart:core 7951 // Second import is the implicit import of dart:core
7890 expect(unlinkedUnits[0].imports, hasLength(2)); 7952 expect(unlinkedUnits[0].imports, hasLength(2));
(...skipping 2596 matching lines...) Expand 10 before | Expand all | Expand 10 after
10487 class _PrefixExpectation { 10549 class _PrefixExpectation {
10488 final ReferenceKind kind; 10550 final ReferenceKind kind;
10489 final String name; 10551 final String name;
10490 final String absoluteUri; 10552 final String absoluteUri;
10491 final String relativeUri; 10553 final String relativeUri;
10492 final int numTypeParameters; 10554 final int numTypeParameters;
10493 10555
10494 _PrefixExpectation(this.kind, this.name, 10556 _PrefixExpectation(this.kind, this.name,
10495 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 10557 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
10496 } 10558 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698