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

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

Issue 2628303002: Fix for crash when part directive uri is has null value. (Closed)
Patch Set: Created 3 years, 11 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_common.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 6453 matching lines...) Expand 10 before | Expand all | Expand 10 after
6464 addNamedSource('/a.dart', 'library my.lib;'); 6464 addNamedSource('/a.dart', 'library my.lib;');
6465 String uriString = '"a.dart"'; 6465 String uriString = '"a.dart"';
6466 String libraryText = 'export $uriString;'; 6466 String libraryText = 'export $uriString;';
6467 serializeLibraryText(libraryText); 6467 serializeLibraryText(libraryText);
6468 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; 6468 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports;
6469 expect(unlinkedExports, hasLength(1)); 6469 expect(unlinkedExports, hasLength(1));
6470 expect(unlinkedExports[0].uri, 'a.dart'); 6470 expect(unlinkedExports[0].uri, 'a.dart');
6471 expect(unlinkedExports[0].configurations, isEmpty); 6471 expect(unlinkedExports[0].configurations, isEmpty);
6472 } 6472 }
6473 6473
6474 test_export_uri_nullStringValue() {
6475 String libraryText = r'''
6476 export "${'a'}.dart";
6477 ''';
6478 serializeLibraryText(libraryText);
6479 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports;
6480 expect(unlinkedExports, hasLength(1));
6481 expect(unlinkedExports[0].uri, '');
6482 expect(unlinkedExports[0].configurations, isEmpty);
6483 }
6484
6474 test_export_variable() { 6485 test_export_variable() {
6475 addNamedSource('/a.dart', 'var v;'); 6486 addNamedSource('/a.dart', 'var v;');
6476 serializeLibraryText('export "a.dart";'); 6487 serializeLibraryText('export "a.dart";');
6477 expect(linked.exportNames, hasLength(2)); 6488 expect(linked.exportNames, hasLength(2));
6478 LinkedExportName getter = 6489 LinkedExportName getter =
6479 linked.exportNames.firstWhere((e) => e.name == 'v'); 6490 linked.exportNames.firstWhere((e) => e.name == 'v');
6480 expect(getter, isNotNull); 6491 expect(getter, isNotNull);
6481 checkExportName(getter, absUri('/a.dart'), 'a.dart', 'v', 6492 checkExportName(getter, absUri('/a.dart'), 'a.dart', 'v',
6482 ReferenceKind.topLevelPropertyAccessor); 6493 ReferenceKind.topLevelPropertyAccessor);
6483 LinkedExportName setter = 6494 LinkedExportName setter =
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
8339 8350
8340 test_import_uri() { 8351 test_import_uri() {
8341 String uriString = '"dart:async"'; 8352 String uriString = '"dart:async"';
8342 String libraryText = 'import $uriString; Future x;'; 8353 String libraryText = 'import $uriString; Future x;';
8343 serializeLibraryText(libraryText); 8354 serializeLibraryText(libraryText);
8344 // Second import is the implicit import of dart:core 8355 // Second import is the implicit import of dart:core
8345 expect(unlinkedUnits[0].imports, hasLength(2)); 8356 expect(unlinkedUnits[0].imports, hasLength(2));
8346 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); 8357 expect(unlinkedUnits[0].imports[0].uri, 'dart:async');
8347 } 8358 }
8348 8359
8360 test_import_uri_nullStringValue() {
8361 String libraryText = r'''
8362 import "${'a'}.dart";
8363 ''';
8364 serializeLibraryText(libraryText);
8365 // Second import is the implicit import of dart:core
8366 expect(unlinkedUnits[0].imports, hasLength(2));
8367 expect(unlinkedUnits[0].imports[0].uri, '');
8368 }
8369
8349 test_inferred_function_type_parameter_type_with_unrelated_type_param() { 8370 test_inferred_function_type_parameter_type_with_unrelated_type_param() {
8350 if (!strongMode || skipFullyLinkedData) { 8371 if (!strongMode || skipFullyLinkedData) {
8351 return; 8372 return;
8352 } 8373 }
8353 // The type that is inferred for C.f's parameter g is "() -> void". 8374 // The type that is inferred for C.f's parameter g is "() -> void".
8354 // Since the associated element for that function type is B.f's parameter g, 8375 // Since the associated element for that function type is B.f's parameter g,
8355 // and B has a type parameter, the inferred type will record a type 8376 // and B has a type parameter, the inferred type will record a type
8356 // parameter. 8377 // parameter.
8357 UnlinkedClass c = serializeClassText(''' 8378 UnlinkedClass c = serializeClassText('''
8358 abstract class B<T> { 8379 abstract class B<T> {
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
9468 addNamedSource('/a.dart', 'part of my.lib;'); 9489 addNamedSource('/a.dart', 'part of my.lib;');
9469 String text = 'library my.lib; part "a.dart"; // <-part'; 9490 String text = 'library my.lib; part "a.dart"; // <-part';
9470 serializeLibraryText(text); 9491 serializeLibraryText(text);
9471 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); 9492 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
9472 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart'); 9493 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart');
9473 expect(unlinkedUnits[0].parts, hasLength(1)); 9494 expect(unlinkedUnits[0].parts, hasLength(1));
9474 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf('"a.dart"')); 9495 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf('"a.dart"'));
9475 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part')); 9496 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part'));
9476 } 9497 }
9477 9498
9499 test_part_declaration_invalidUri_nullStringValue() {
9500 addNamedSource('/a.dart', 'part of my.lib;');
9501 String text = r'''
9502 library my.lib;
9503 part "${'a'}.dart"; // <-part
9504 ''';
9505 serializeLibraryText(text);
9506 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
9507 expect(unlinkedUnits[0].publicNamespace.parts[0], '');
9508 expect(unlinkedUnits[0].parts, hasLength(1));
9509 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf(r'"${'));
9510 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part'));
9511 }
9512
9478 test_part_isPartOf() { 9513 test_part_isPartOf() {
9479 addNamedSource('/a.dart', 'part of foo; class C {}'); 9514 addNamedSource('/a.dart', 'part of foo; class C {}');
9480 serializeLibraryText('library foo; part "a.dart";'); 9515 serializeLibraryText('library foo; part "a.dart";');
9481 expect(unlinkedUnits[0].isPartOf, isFalse); 9516 expect(unlinkedUnits[0].isPartOf, isFalse);
9482 expect(unlinkedUnits[1].isPartOf, isTrue); 9517 expect(unlinkedUnits[1].isPartOf, isTrue);
9483 } 9518 }
9484 9519
9485 test_parts_defining_compilation_unit() { 9520 test_parts_defining_compilation_unit() {
9486 serializeLibraryText(''); 9521 serializeLibraryText('');
9487 expect(linked.units, hasLength(1)); 9522 expect(linked.units, hasLength(1));
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
10577 class _PrefixExpectation { 10612 class _PrefixExpectation {
10578 final ReferenceKind kind; 10613 final ReferenceKind kind;
10579 final String name; 10614 final String name;
10580 final String absoluteUri; 10615 final String absoluteUri;
10581 final String relativeUri; 10616 final String relativeUri;
10582 final int numTypeParameters; 10617 final int numTypeParameters;
10583 10618
10584 _PrefixExpectation(this.kind, this.name, 10619 _PrefixExpectation(this.kind, this.name,
10585 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 10620 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
10586 } 10621 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_common.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698