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

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

Issue 2669863003: Handle invalid URIs in summaries. (Closed)
Patch Set: Remove uri.dart, tweak for summarize_ast_test. Created 3 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/summarize_ast_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/error/listener.dart'; 9 import 'package:analyzer/error/listener.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 6463 matching lines...) Expand 10 before | Expand all | Expand 10 after
6474 addNamedSource('/a.dart', 'library my.lib;'); 6474 addNamedSource('/a.dart', 'library my.lib;');
6475 String uriString = '"a.dart"'; 6475 String uriString = '"a.dart"';
6476 String libraryText = 'export $uriString;'; 6476 String libraryText = 'export $uriString;';
6477 serializeLibraryText(libraryText); 6477 serializeLibraryText(libraryText);
6478 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; 6478 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports;
6479 expect(unlinkedExports, hasLength(1)); 6479 expect(unlinkedExports, hasLength(1));
6480 expect(unlinkedExports[0].uri, 'a.dart'); 6480 expect(unlinkedExports[0].uri, 'a.dart');
6481 expect(unlinkedExports[0].configurations, isEmpty); 6481 expect(unlinkedExports[0].configurations, isEmpty);
6482 } 6482 }
6483 6483
6484 test_export_uri_invalid() {
6485 String uriString = '[invalid uri]';
6486 String libraryText = 'export "$uriString";';
6487 serializeLibraryText(libraryText);
6488 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
6489 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, uriString);
6490 }
6491
6484 test_export_uri_nullStringValue() { 6492 test_export_uri_nullStringValue() {
6485 String libraryText = r''' 6493 String libraryText = r'''
6486 export "${'a'}.dart"; 6494 export "${'a'}.dart";
6487 '''; 6495 ''';
6488 serializeLibraryText(libraryText); 6496 serializeLibraryText(libraryText);
6489 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; 6497 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports;
6490 expect(unlinkedExports, hasLength(1)); 6498 expect(unlinkedExports, hasLength(1));
6491 expect(unlinkedExports[0].uri, ''); 6499 expect(unlinkedExports[0].uri, '');
6492 expect(unlinkedExports[0].configurations, isEmpty); 6500 expect(unlinkedExports[0].configurations, isEmpty);
6493 } 6501 }
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
8397 8405
8398 test_import_uri() { 8406 test_import_uri() {
8399 String uriString = '"dart:async"'; 8407 String uriString = '"dart:async"';
8400 String libraryText = 'import $uriString; Future x;'; 8408 String libraryText = 'import $uriString; Future x;';
8401 serializeLibraryText(libraryText); 8409 serializeLibraryText(libraryText);
8402 // Second import is the implicit import of dart:core 8410 // Second import is the implicit import of dart:core
8403 expect(unlinkedUnits[0].imports, hasLength(2)); 8411 expect(unlinkedUnits[0].imports, hasLength(2));
8404 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); 8412 expect(unlinkedUnits[0].imports[0].uri, 'dart:async');
8405 } 8413 }
8406 8414
8415 test_import_uri_invalid() {
8416 String uriString = '[invalid uri]';
8417 String libraryText = 'import "$uriString";';
8418 serializeLibraryText(libraryText);
8419 // Second import is the implicit import of dart:core
8420 expect(unlinkedUnits[0].imports, hasLength(2));
8421 expect(unlinkedUnits[0].imports[0].uri, uriString);
8422 }
8423
8407 test_import_uri_nullStringValue() { 8424 test_import_uri_nullStringValue() {
8408 String libraryText = r''' 8425 String libraryText = r'''
8409 import "${'a'}.dart"; 8426 import "${'a'}.dart";
8410 '''; 8427 ''';
8411 serializeLibraryText(libraryText); 8428 serializeLibraryText(libraryText);
8412 // Second import is the implicit import of dart:core 8429 // Second import is the implicit import of dart:core
8413 expect(unlinkedUnits[0].imports, hasLength(2)); 8430 expect(unlinkedUnits[0].imports, hasLength(2));
8414 expect(unlinkedUnits[0].imports[0].uri, ''); 8431 expect(unlinkedUnits[0].imports[0].uri, '');
8415 } 8432 }
8416 8433
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
9595 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part')); 9612 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part'));
9596 } 9613 }
9597 9614
9598 test_part_isPartOf() { 9615 test_part_isPartOf() {
9599 addNamedSource('/a.dart', 'part of foo; class C {}'); 9616 addNamedSource('/a.dart', 'part of foo; class C {}');
9600 serializeLibraryText('library foo; part "a.dart";'); 9617 serializeLibraryText('library foo; part "a.dart";');
9601 expect(unlinkedUnits[0].isPartOf, isFalse); 9618 expect(unlinkedUnits[0].isPartOf, isFalse);
9602 expect(unlinkedUnits[1].isPartOf, isTrue); 9619 expect(unlinkedUnits[1].isPartOf, isTrue);
9603 } 9620 }
9604 9621
9622 test_part_uri_invalid() {
9623 String uriString = '[invalid uri]';
9624 String libraryText = 'part "$uriString";';
9625 serializeLibraryText(libraryText);
9626 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
9627 expect(unlinkedUnits[0].publicNamespace.parts[0], uriString);
9628 }
9629
9605 test_parts_defining_compilation_unit() { 9630 test_parts_defining_compilation_unit() {
9606 serializeLibraryText(''); 9631 serializeLibraryText('');
9607 expect(linked.units, hasLength(1)); 9632 expect(linked.units, hasLength(1));
9608 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty); 9633 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty);
9609 } 9634 }
9610 9635
9611 test_parts_included() { 9636 test_parts_included() {
9612 addNamedSource('/part1.dart', 'part of my.lib;'); 9637 addNamedSource('/part1.dart', 'part of my.lib;');
9613 String partString = '"part1.dart"'; 9638 String partString = '"part1.dart"';
9614 String libraryText = 'library my.lib; part $partString;'; 9639 String libraryText = 'library my.lib; part $partString;';
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
10708 class _PrefixExpectation { 10733 class _PrefixExpectation {
10709 final ReferenceKind kind; 10734 final ReferenceKind kind;
10710 final String name; 10735 final String name;
10711 final String absoluteUri; 10736 final String absoluteUri;
10712 final String relativeUri; 10737 final String relativeUri;
10713 final int numTypeParameters; 10738 final int numTypeParameters;
10714 10739
10715 _PrefixExpectation(this.kind, this.name, 10740 _PrefixExpectation(this.kind, this.name,
10716 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 10741 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
10717 } 10742 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/summarize_ast_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698