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

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

Issue 2671513002: Revert "Encode URIs stored in unlinked summaries to make them Uri.parse() safe." (Closed)
Patch Set: 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/dart/analysis/file_state_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 allowMissingFiles = true;
6486 String uri = '[invalid uri]';
6487 String libraryText = 'export "$uri";';
6488 serializeLibraryText(libraryText);
6489 UnlinkedPublicNamespace publicNamespace = unlinkedUnits[0].publicNamespace;
6490 expect(publicNamespace.exports, hasLength(1));
6491 expect(publicNamespace.exports[0].uri, Uri.encodeFull(uri));
6492 }
6493
6494 test_export_uri_nullStringValue() { 6484 test_export_uri_nullStringValue() {
6495 String libraryText = r''' 6485 String libraryText = r'''
6496 export "${'a'}.dart"; 6486 export "${'a'}.dart";
6497 '''; 6487 ''';
6498 serializeLibraryText(libraryText); 6488 serializeLibraryText(libraryText);
6499 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; 6489 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports;
6500 expect(unlinkedExports, hasLength(1)); 6490 expect(unlinkedExports, hasLength(1));
6501 expect(unlinkedExports[0].uri, ''); 6491 expect(unlinkedExports[0].uri, '');
6502 expect(unlinkedExports[0].configurations, isEmpty); 6492 expect(unlinkedExports[0].configurations, isEmpty);
6503 } 6493 }
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
8407 8397
8408 test_import_uri() { 8398 test_import_uri() {
8409 String uriString = '"dart:async"'; 8399 String uriString = '"dart:async"';
8410 String libraryText = 'import $uriString; Future x;'; 8400 String libraryText = 'import $uriString; Future x;';
8411 serializeLibraryText(libraryText); 8401 serializeLibraryText(libraryText);
8412 // Second import is the implicit import of dart:core 8402 // Second import is the implicit import of dart:core
8413 expect(unlinkedUnits[0].imports, hasLength(2)); 8403 expect(unlinkedUnits[0].imports, hasLength(2));
8414 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); 8404 expect(unlinkedUnits[0].imports[0].uri, 'dart:async');
8415 } 8405 }
8416 8406
8417 test_import_uri_invalid() {
8418 allowMissingFiles = true;
8419 String uri = '[invalid uri]';
8420 String libraryText = 'import "$uri";';
8421 serializeLibraryText(libraryText);
8422 // Second import is the implicit import of dart:core
8423 expect(unlinkedUnits[0].imports, hasLength(2));
8424 expect(unlinkedUnits[0].imports[0].uri, Uri.encodeFull(uri));
8425 }
8426
8427 test_import_uri_nullStringValue() { 8407 test_import_uri_nullStringValue() {
8428 String libraryText = r''' 8408 String libraryText = r'''
8429 import "${'a'}.dart"; 8409 import "${'a'}.dart";
8430 '''; 8410 ''';
8431 serializeLibraryText(libraryText); 8411 serializeLibraryText(libraryText);
8432 // Second import is the implicit import of dart:core 8412 // Second import is the implicit import of dart:core
8433 expect(unlinkedUnits[0].imports, hasLength(2)); 8413 expect(unlinkedUnits[0].imports, hasLength(2));
8434 expect(unlinkedUnits[0].imports[0].uri, ''); 8414 expect(unlinkedUnits[0].imports[0].uri, '');
8435 } 8415 }
8436 8416
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
9615 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part')); 9595 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part'));
9616 } 9596 }
9617 9597
9618 test_part_isPartOf() { 9598 test_part_isPartOf() {
9619 addNamedSource('/a.dart', 'part of foo; class C {}'); 9599 addNamedSource('/a.dart', 'part of foo; class C {}');
9620 serializeLibraryText('library foo; part "a.dart";'); 9600 serializeLibraryText('library foo; part "a.dart";');
9621 expect(unlinkedUnits[0].isPartOf, isFalse); 9601 expect(unlinkedUnits[0].isPartOf, isFalse);
9622 expect(unlinkedUnits[1].isPartOf, isTrue); 9602 expect(unlinkedUnits[1].isPartOf, isTrue);
9623 } 9603 }
9624 9604
9625 test_part_uri_invalid() {
9626 allowMissingFiles = true;
9627 String uri = '[invalid uri]';
9628 String libraryText = 'part "$uri";';
9629 serializeLibraryText(libraryText);
9630 UnlinkedPublicNamespace publicNamespace = unlinkedUnits[0].publicNamespace;
9631 expect(publicNamespace.parts, hasLength(1));
9632 expect(publicNamespace.parts[0], Uri.encodeFull(uri));
9633 }
9634
9635 test_parts_defining_compilation_unit() { 9605 test_parts_defining_compilation_unit() {
9636 serializeLibraryText(''); 9606 serializeLibraryText('');
9637 expect(linked.units, hasLength(1)); 9607 expect(linked.units, hasLength(1));
9638 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty); 9608 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty);
9639 } 9609 }
9640 9610
9641 test_parts_included() { 9611 test_parts_included() {
9642 addNamedSource('/part1.dart', 'part of my.lib;'); 9612 addNamedSource('/part1.dart', 'part of my.lib;');
9643 String partString = '"part1.dart"'; 9613 String partString = '"part1.dart"';
9644 String libraryText = 'library my.lib; part $partString;'; 9614 String libraryText = 'library my.lib; part $partString;';
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
10738 class _PrefixExpectation { 10708 class _PrefixExpectation {
10739 final ReferenceKind kind; 10709 final ReferenceKind kind;
10740 final String name; 10710 final String name;
10741 final String absoluteUri; 10711 final String absoluteUri;
10742 final String relativeUri; 10712 final String relativeUri;
10743 final int numTypeParameters; 10713 final int numTypeParameters;
10744 10714
10745 _PrefixExpectation(this.kind, this.name, 10715 _PrefixExpectation(this.kind, this.name,
10746 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 10716 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
10747 } 10717 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/dart/analysis/file_state_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698