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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 2353433002: Use configurations and declared variables to select import/export URIs during prelinking. (Closed)
Patch Set: Cache selected URI. 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/summary/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index 7ad3f5beee8c6aee9529aba182551f30f951aac2..7f1d44bc0f82eb57afcf1cdbc0a3aba260e12e30 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -3030,6 +3030,51 @@ main(F f) {}
checkLibrary('export "a.dart";');
}
+ test_export_configurations_useDefault() {
+ context.declaredVariables.define('dart.library.io', 'false');
+ addLibrarySource('/foo.dart', 'class A {}');
+ addLibrarySource('/foo_io.dart', 'class A {}');
+ addLibrarySource('/foo_html.dart', 'class A {}');
+ LibraryElementImpl library = checkLibrary(r'''
+export 'foo.dart'
+ if (dart.library.io) 'foo_io.dart'
+ if (dart.library.html) 'foo_html.dart';
+''');
+ expect(library.exports[0].uri, 'foo.dart');
+ expect(library.exports[0].exportedLibrary.source.shortName, 'foo.dart');
+ }
+
+ test_export_configurations_useFirst() {
+ context.declaredVariables.define('dart.library.io', 'true');
+ context.declaredVariables.define('dart.library.html', 'true');
+ addLibrarySource('/foo.dart', 'class A {}');
+ addLibrarySource('/foo_io.dart', 'class A {}');
+ addLibrarySource('/foo_html.dart', 'class A {}');
+ LibraryElementImpl library = checkLibrary(r'''
+export 'foo.dart'
+ if (dart.library.io) 'foo_io.dart'
+ if (dart.library.html) 'foo_html.dart';
+''');
+ expect(library.exports[0].uri, 'foo_io.dart');
+ expect(library.exports[0].exportedLibrary.source.shortName, 'foo_io.dart');
+ }
+
+ test_export_configurations_useSecond() {
+ context.declaredVariables.define('dart.library.io', 'false');
+ context.declaredVariables.define('dart.library.html', 'true');
+ addLibrarySource('/foo.dart', 'class A {}');
+ addLibrarySource('/foo_io.dart', 'class A {}');
+ addLibrarySource('/foo_html.dart', 'class A {}');
+ LibraryElementImpl library = checkLibrary(r'''
+export 'foo.dart'
+ if (dart.library.io) 'foo_io.dart'
+ if (dart.library.html) 'foo_html.dart';
+''');
+ ExportElement export = library.exports[0];
+ expect(export.uri, 'foo_html.dart');
+ expect(export.exportedLibrary.source.shortName, 'foo_html.dart');
+ }
+
test_export_function() {
addLibrarySource('/a.dart', 'f() {}');
checkLibrary('export "a.dart";');
@@ -3080,6 +3125,47 @@ main(F f) {}
checkLibrary('export "a.dart";');
}
+ test_exportImport_configurations_useDefault() {
+ context.declaredVariables.define('dart.library.io', 'false');
+ addLibrarySource('/foo.dart', 'class A {}');
+ addLibrarySource('/foo_io.dart', 'class A {}');
+ addLibrarySource('/foo_html.dart', 'class A {}');
+ addLibrarySource(
+ '/bar.dart',
+ r'''
+export 'foo.dart'
+ if (dart.library.io) 'foo_io.dart'
+ if (dart.library.html) 'foo_html.dart';
+''');
+ LibraryElementImpl library = checkLibrary(r'''
+import 'bar.dart';
+class B extends A {}
+''');
+ var typeA = library.definingCompilationUnit.getType('B').supertype;
+ expect(typeA.element.source.shortName, 'foo.dart');
+ }
+
+ test_exportImport_configurations_useFirst() {
+ context.declaredVariables.define('dart.library.io', 'true');
+ context.declaredVariables.define('dart.library.html', 'true');
+ addLibrarySource('/foo.dart', 'class A {}');
+ addLibrarySource('/foo_io.dart', 'class A {}');
+ addLibrarySource('/foo_html.dart', 'class A {}');
+ addLibrarySource(
+ '/bar.dart',
+ r'''
+export 'foo.dart'
+ if (dart.library.io) 'foo_io.dart'
+ if (dart.library.html) 'foo_html.dart';
+''');
+ var library = checkLibrary(r'''
+import 'bar.dart';
+class B extends A {}
+''');
+ var typeA = library.definingCompilationUnit.getType('B').supertype;
+ expect(typeA.element.source.shortName, 'foo_io.dart');
+ }
+
test_exports() {
addLibrarySource('/a.dart', 'library a;');
addLibrarySource('/b.dart', 'library b;');
@@ -3394,6 +3480,39 @@ get x => null;''');
checkLibrary('void set x(int value) {} int get x => 0;');
}
+ test_import_configurations_useDefault() {
+ context.declaredVariables.define('dart.library.io', 'false');
+ addLibrarySource('/foo.dart', 'class A {}');
+ addLibrarySource('/foo_io.dart', 'class A {}');
+ addLibrarySource('/foo_html.dart', 'class A {}');
+ var library = checkLibrary(r'''
+import 'foo.dart'
+ if (dart.library.io) 'foo_io.dart'
+ if (dart.library.html) 'foo_html.dart';
+
+class B extends A {}
+''');
+ var typeA = library.definingCompilationUnit.getType('B').supertype;
+ expect(typeA.element.source.shortName, 'foo.dart');
+ }
+
+ test_import_configurations_useFirst() {
+ context.declaredVariables.define('dart.library.io', 'true');
+ context.declaredVariables.define('dart.library.html', 'true');
+ addLibrarySource('/foo.dart', 'class A {}');
+ addLibrarySource('/foo_io.dart', 'class A {}');
+ addLibrarySource('/foo_html.dart', 'class A {}');
+ var library = checkLibrary(r'''
+import 'foo.dart'
+ if (dart.library.io) 'foo_io.dart'
+ if (dart.library.html) 'foo_html.dart';
+
+class B extends A {}
+''');
+ var typeA = library.definingCompilationUnit.getType('B').supertype;
+ expect(typeA.element.source.shortName, 'foo_io.dart');
+ }
+
test_import_deferred() {
addLibrarySource('/a.dart', 'f() {}');
checkLibrary('import "a.dart" deferred as p; main() { p.f(); }');
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_ast_test.dart ('k') | pkg/analyzer/test/src/summary/summarize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698