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

Side by Side Diff: tests/compiler/dart2js/library_resolution_test.dart

Issue 1884793002: dart2js: remove references to compiler in ResolvedUriTranslator (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Check that relative URIs are resolved against the canonical name of a 5 /// Check that relative URIs are resolved against the canonical name of a
6 /// library. This only matters for dart:-libraries, so this test mocks up two 6 /// library. This only matters for dart:-libraries, so this test mocks up two
7 /// dart:-libraries. 7 /// dart:-libraries.
8 8
9 import "dart:io"; 9 import "dart:io";
10 10
(...skipping 19 matching lines...) Expand all
30 Uri sdkRoot = Uri.base.resolve("sdk/"); 30 Uri sdkRoot = Uri.base.resolve("sdk/");
31 Uri mock1LibraryUri = sdkRoot.resolve("lib/mock1.dart"); 31 Uri mock1LibraryUri = sdkRoot.resolve("lib/mock1.dart");
32 Uri mock2LibraryUri = sdkRoot.resolve("lib/mock2.dart"); 32 Uri mock2LibraryUri = sdkRoot.resolve("lib/mock2.dart");
33 33
34 class CustomCompiler extends CompilerImpl { 34 class CustomCompiler extends CompilerImpl {
35 CustomCompiler(provider, handler, libraryRoot, packageRoot) 35 CustomCompiler(provider, handler, libraryRoot, packageRoot)
36 : super(provider, const NullCompilerOutput(), handler, 36 : super(provider, const NullCompilerOutput(), handler,
37 new CompilerOptions( 37 new CompilerOptions(
38 libraryRoot: libraryRoot, 38 libraryRoot: libraryRoot,
39 packageRoot: packageRoot)); 39 packageRoot: packageRoot));
40
41 Uri lookupLibraryUri(String libraryName) {
42 if (libraryName == "m_o_c_k_1") return mock1LibraryUri;
43 if (libraryName == "m_o_c_k_2") return mock2LibraryUri;
44 return super.lookupLibraryUri(libraryName);
45 }
46 } 40 }
47 41
48 main() async { 42 main() async {
49 Uri packageRoot = Uri.base.resolve(Platform.packageRoot); 43 Uri packageRoot = Uri.base.resolve(Platform.packageRoot);
50 44
51 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); 45 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
52 var handler = new FormattingDiagnosticHandler(provider); 46 var handler = new FormattingDiagnosticHandler(provider);
53 47
54 Future wrappedProvider(Uri uri) { 48 Future wrappedProvider(Uri uri) {
55 if (uri == mock1LibraryUri) { 49 if (uri == mock1LibraryUri) {
(...skipping 24 matching lines...) Expand all
80 } 74 }
81 75
82 CompilerImpl compiler = new CustomCompiler( 76 CompilerImpl compiler = new CustomCompiler(
83 new LegacyCompilerInput(wrappedProvider), 77 new LegacyCompilerInput(wrappedProvider),
84 new LegacyCompilerDiagnostics(wrappedHandler), 78 new LegacyCompilerDiagnostics(wrappedHandler),
85 sdkRoot, 79 sdkRoot,
86 packageRoot); 80 packageRoot);
87 81
88 asyncStart(); 82 asyncStart();
89 await compiler.setupSdk(); 83 await compiler.setupSdk();
84 // TODO(het): Find cleaner way to do this
85 compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_1'] = mock1LibraryUri;
86 compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_2'] = mock2LibraryUri;
90 var library = 87 var library =
91 await compiler.libraryLoader.loadLibrary(Uri.parse("dart:m_o_c_k_1")); 88 await compiler.libraryLoader.loadLibrary(Uri.parse("dart:m_o_c_k_1"));
92 await checkLibrary(library); 89 await checkLibrary(library);
93 asyncSuccess(null); 90 asyncSuccess(null);
94 } 91 }
95 92
96 const Map MEMORY_SOURCE_FILES = const { 93 const Map MEMORY_SOURCE_FILES = const {
97 "mock1.dart": "library mock1; import 'mock2.dart';", 94 "mock1.dart": "library mock1; import 'mock2.dart';",
98 "mock2.dart": "library mock2;", 95 "mock2.dart": "library mock2;",
99 }; 96 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698