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

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

Issue 1714173002: Add summary support for ShowElementCombinator.end and .offset. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/src/summary/resynthesize_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) 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/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 4871 matching lines...) Expand 10 before | Expand all | Expand 10 after
4882 expect( 4882 expect(
4883 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); 4883 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1));
4884 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, 4884 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows,
4885 isEmpty); 4885 isEmpty);
4886 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, 4886 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides,
4887 hasLength(2)); 4887 hasLength(2));
4888 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[0], 4888 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[0],
4889 'Future'); 4889 'Future');
4890 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[1], 4890 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[1],
4891 'Stream'); 4891 'Stream');
4892 expect(
4893 unlinkedUnits[0].publicNamespace.exports[0].combinators[0].offset, 0);
4894 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].end, 0);
4892 expect(linked.exportNames, isNotEmpty); 4895 expect(linked.exportNames, isNotEmpty);
4893 } 4896 }
4894 4897
4895 test_export_names_excludes_names_from_library() { 4898 test_export_names_excludes_names_from_library() {
4896 addNamedSource('/a.dart', 'part of my.lib; int y; int _y;'); 4899 addNamedSource('/a.dart', 'part of my.lib; int y; int _y;');
4897 serializeLibraryText('library my.lib; part "a.dart"; int x; int _x;'); 4900 serializeLibraryText('library my.lib; part "a.dart"; int x; int _x;');
4898 expect(linked.exportNames, isEmpty); 4901 expect(linked.exportNames, isEmpty);
4899 } 4902 }
4900 4903
4901 test_export_no_combinators() { 4904 test_export_no_combinators() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4974 4977
4975 test_export_show() { 4978 test_export_show() {
4976 addNamedSource('/a.dart', 'f() {} g() {}'); 4979 addNamedSource('/a.dart', 'f() {} g() {}');
4977 serializeLibraryText('export "a.dart" show f;'); 4980 serializeLibraryText('export "a.dart" show f;');
4978 expect(linked.exportNames, hasLength(1)); 4981 expect(linked.exportNames, hasLength(1));
4979 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', 4982 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f',
4980 ReferenceKind.topLevelFunction); 4983 ReferenceKind.topLevelFunction);
4981 } 4984 }
4982 4985
4983 test_export_show_order() { 4986 test_export_show_order() {
4984 serializeLibraryText('export "dart:async" show Future, Stream;'); 4987 String libraryText = 'export "dart:async" show Future, Stream;';
4988 serializeLibraryText(libraryText);
4985 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); 4989 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
4986 expect( 4990 expect(
4987 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); 4991 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1));
4988 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, 4992 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows,
4989 hasLength(2)); 4993 hasLength(2));
4990 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, 4994 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides,
4991 isEmpty); 4995 isEmpty);
4992 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0], 4996 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0],
4993 'Future'); 4997 'Future');
4994 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[1], 4998 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[1],
4995 'Stream'); 4999 'Stream');
5000 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].offset,
5001 libraryText.indexOf('show'));
5002 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].end,
5003 libraryText.indexOf(';'));
4996 } 5004 }
4997 5005
4998 test_export_typedef() { 5006 test_export_typedef() {
4999 addNamedSource('/a.dart', 'typedef F();'); 5007 addNamedSource('/a.dart', 'typedef F();');
5000 serializeLibraryText('export "a.dart";'); 5008 serializeLibraryText('export "a.dart";');
5001 expect(linked.exportNames, hasLength(1)); 5009 expect(linked.exportNames, hasLength(1));
5002 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'F', 5010 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'F',
5003 ReferenceKind.typedef); 5011 ReferenceKind.typedef);
5004 } 5012 }
5005 5013
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 test_import_hide_order() { 5328 test_import_hide_order() {
5321 serializeLibraryText( 5329 serializeLibraryText(
5322 'import "dart:async" hide Future, Stream; Completer c;'); 5330 'import "dart:async" hide Future, Stream; Completer c;');
5323 // Second import is the implicit import of dart:core 5331 // Second import is the implicit import of dart:core
5324 expect(unlinkedUnits[0].imports, hasLength(2)); 5332 expect(unlinkedUnits[0].imports, hasLength(2));
5325 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); 5333 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1));
5326 expect(unlinkedUnits[0].imports[0].combinators[0].shows, isEmpty); 5334 expect(unlinkedUnits[0].imports[0].combinators[0].shows, isEmpty);
5327 expect(unlinkedUnits[0].imports[0].combinators[0].hides, hasLength(2)); 5335 expect(unlinkedUnits[0].imports[0].combinators[0].hides, hasLength(2));
5328 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future'); 5336 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future');
5329 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream'); 5337 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream');
5338 expect(unlinkedUnits[0].imports[0].combinators[0].offset, 0);
5339 expect(unlinkedUnits[0].imports[0].combinators[0].end, 0);
5330 } 5340 }
5331 5341
5332 test_import_implicit() { 5342 test_import_implicit() {
5333 // The implicit import of dart:core is represented in the model. 5343 // The implicit import of dart:core is represented in the model.
5334 serializeLibraryText(''); 5344 serializeLibraryText('');
5335 expect(unlinkedUnits[0].imports, hasLength(1)); 5345 expect(unlinkedUnits[0].imports, hasLength(1));
5336 checkDependency(linked.importDependencies[0], 'dart:core', 'dart:core'); 5346 checkDependency(linked.importDependencies[0], 'dart:core', 'dart:core');
5337 expect(unlinkedUnits[0].imports[0].uri, isEmpty); 5347 expect(unlinkedUnits[0].imports[0].uri, isEmpty);
5338 expect(unlinkedUnits[0].imports[0].uriOffset, 0); 5348 expect(unlinkedUnits[0].imports[0].uriOffset, 0);
5339 expect(unlinkedUnits[0].imports[0].uriEnd, 0); 5349 expect(unlinkedUnits[0].imports[0].uriEnd, 0);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
5512 String libraryText = 5522 String libraryText =
5513 'import "dart:async" show Future, Stream; Future x; Stream y;'; 5523 'import "dart:async" show Future, Stream; Future x; Stream y;';
5514 serializeLibraryText(libraryText); 5524 serializeLibraryText(libraryText);
5515 // Second import is the implicit import of dart:core 5525 // Second import is the implicit import of dart:core
5516 expect(unlinkedUnits[0].imports, hasLength(2)); 5526 expect(unlinkedUnits[0].imports, hasLength(2));
5517 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); 5527 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1));
5518 expect(unlinkedUnits[0].imports[0].combinators[0].shows, hasLength(2)); 5528 expect(unlinkedUnits[0].imports[0].combinators[0].shows, hasLength(2));
5519 expect(unlinkedUnits[0].imports[0].combinators[0].hides, isEmpty); 5529 expect(unlinkedUnits[0].imports[0].combinators[0].hides, isEmpty);
5520 expect(unlinkedUnits[0].imports[0].combinators[0].shows[0], 'Future'); 5530 expect(unlinkedUnits[0].imports[0].combinators[0].shows[0], 'Future');
5521 expect(unlinkedUnits[0].imports[0].combinators[0].shows[1], 'Stream'); 5531 expect(unlinkedUnits[0].imports[0].combinators[0].shows[1], 'Stream');
5532 expect(unlinkedUnits[0].imports[0].combinators[0].offset,
5533 libraryText.indexOf('show'));
5534 expect(unlinkedUnits[0].imports[0].combinators[0].end,
5535 libraryText.indexOf('; Future'));
5522 } 5536 }
5523 5537
5524 test_import_uri() { 5538 test_import_uri() {
5525 String uriString = '"dart:async"'; 5539 String uriString = '"dart:async"';
5526 String libraryText = 'import $uriString; Future x;'; 5540 String libraryText = 'import $uriString; Future x;';
5527 serializeLibraryText(libraryText); 5541 serializeLibraryText(libraryText);
5528 // Second import is the implicit import of dart:core 5542 // Second import is the implicit import of dart:core
5529 expect(unlinkedUnits[0].imports, hasLength(2)); 5543 expect(unlinkedUnits[0].imports, hasLength(2));
5530 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); 5544 expect(unlinkedUnits[0].imports[0].uri, 'dart:async');
5531 } 5545 }
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
7304 class _PrefixExpectation { 7318 class _PrefixExpectation {
7305 final ReferenceKind kind; 7319 final ReferenceKind kind;
7306 final String name; 7320 final String name;
7307 final String absoluteUri; 7321 final String absoluteUri;
7308 final String relativeUri; 7322 final String relativeUri;
7309 final int numTypeParameters; 7323 final int numTypeParameters;
7310 7324
7311 _PrefixExpectation(this.kind, this.name, 7325 _PrefixExpectation(this.kind, this.name,
7312 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 7326 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
7313 } 7327 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698