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

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

Issue 2760923004: Eliminate multi-callback structure for LibraryLoader. (Closed)
Patch Set: . Created 3 years, 9 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
11 import "dart:async"; 11 import "dart:async";
12 12
13 import "memory_source_file_helper.dart"; 13 import "memory_source_file_helper.dart";
14 14
15 import "package:async_helper/async_helper.dart"; 15 import "package:async_helper/async_helper.dart";
16 16
17 import 'package:expect/expect.dart' show Expect; 17 import 'package:expect/expect.dart' show Expect;
18 18
19 import 'package:compiler/src/diagnostics/messages.dart' 19 import 'package:compiler/src/diagnostics/messages.dart'
20 show MessageKind, MessageTemplate; 20 show MessageKind, MessageTemplate;
21 21
22 import 'package:compiler/src/elements/elements.dart' show LibraryElement; 22 import 'package:compiler/src/elements/elements.dart' show LibraryElement;
23 23
24 import 'package:compiler/src/library_loader.dart' show LoadedLibraries;
25
24 import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput; 26 import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput;
25 27
26 import 'package:compiler/src/old_to_new_api.dart' 28 import 'package:compiler/src/old_to_new_api.dart'
27 show LegacyCompilerDiagnostics, LegacyCompilerInput; 29 show LegacyCompilerDiagnostics, LegacyCompilerInput;
28 import 'package:compiler/src/options.dart' show CompilerOptions; 30 import 'package:compiler/src/options.dart' show CompilerOptions;
29 31
30 Uri sdkRoot = Uri.base.resolve("sdk/"); 32 Uri sdkRoot = Uri.base.resolve("sdk/");
31 Uri mock1LibraryUri = sdkRoot.resolve("lib/mock1.dart"); 33 Uri mock1LibraryUri = sdkRoot.resolve("lib/mock1.dart");
32 Uri mock2LibraryUri = sdkRoot.resolve("lib/mock2.dart"); 34 Uri mock2LibraryUri = sdkRoot.resolve("lib/mock2.dart");
33 35
(...skipping 30 matching lines...) Expand all
64 int actualMessageCount = 0; 66 int actualMessageCount = 0;
65 67
66 wrappedHandler(Uri uri, int begin, int end, String message, kind) { 68 wrappedHandler(Uri uri, int begin, int end, String message, kind) {
67 if (message == expectedMessage) { 69 if (message == expectedMessage) {
68 actualMessageCount++; 70 actualMessageCount++;
69 } else { 71 } else {
70 return handler(uri, begin, end, message, kind); 72 return handler(uri, begin, end, message, kind);
71 } 73 }
72 } 74 }
73 75
74 checkLibrary(LibraryElement library) { 76 checkLibrary(LoadedLibraries libraries) {
Siggi Cherem (dart-lang) 2017/03/24 17:40:28 checkLibrary => checkLibraries?
Emily Fortuna 2017/03/24 18:30:20 Done.
75 Expect.equals(1, actualMessageCount); 77 Expect.equals(1, actualMessageCount);
76 } 78 }
77 79
78 CompilerImpl compiler = new CustomCompiler( 80 CompilerImpl compiler = new CustomCompiler(
79 new LegacyCompilerInput(wrappedProvider), 81 new LegacyCompilerInput(wrappedProvider),
80 new LegacyCompilerDiagnostics(wrappedHandler), 82 new LegacyCompilerDiagnostics(wrappedHandler),
81 sdkRoot, 83 sdkRoot,
82 packageConfig); 84 packageConfig);
83 85
84 asyncStart(); 86 asyncStart();
85 await compiler.setupSdk(); 87 await compiler.setupSdk();
86 // TODO(het): Find cleaner way to do this 88 // TODO(het): Find cleaner way to do this
87 compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_1'] = mock1LibraryUri; 89 compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_1'] = mock1LibraryUri;
88 compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_2'] = mock2LibraryUri; 90 compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_2'] = mock2LibraryUri;
89 var library = 91 var libraries =
90 await compiler.libraryLoader.loadLibrary(Uri.parse("dart:m_o_c_k_1")); 92 await compiler.libraryLoader.loadLibrary(Uri.parse("dart:m_o_c_k_1"));
91 await checkLibrary(library); 93 await checkLibrary(libraries);
92 asyncSuccess(null); 94 asyncSuccess(null);
93 } 95 }
94 96
95 const Map MEMORY_SOURCE_FILES = const { 97 const Map MEMORY_SOURCE_FILES = const {
96 "mock1.dart": "library mock1; import 'mock2.dart';", 98 "mock1.dart": "library mock1; import 'mock2.dart';",
97 "mock2.dart": "library mock2;", 99 "mock2.dart": "library mock2;",
98 }; 100 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698