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

Side by Side Diff: tests/compiler/dart2js/kernel/visitor_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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// Test that the dart2js copy of [KernelVisitor] generates the expected IR as 5 /// Test that the dart2js copy of [KernelVisitor] generates the expected IR as
6 /// defined by kernel spec-mode test files. 6 /// defined by kernel spec-mode test files.
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:async'; 9 import 'dart:async';
10 import 'package:compiler/src/compiler.dart' show Compiler; 10 import 'package:compiler/src/compiler.dart' show Compiler;
(...skipping 23 matching lines...) Expand all
34 String name = pathlib.basenameWithoutExtension(file.path); 34 String name = pathlib.basenameWithoutExtension(file.path);
35 bool selected = arguments.contains(name); 35 bool selected = arguments.contains(name);
36 if (!selected) { 36 if (!selected) {
37 if (arguments.isNotEmpty) continue; 37 if (arguments.isNotEmpty) continue;
38 if (SKIP_TESTS.contains(name)) continue; 38 if (SKIP_TESTS.contains(name)) continue;
39 } 39 }
40 40
41 test(name, () async { 41 test(name, () async {
42 var compiler = await newCompiler(); 42 var compiler = await newCompiler();
43 await compiler.run(file.absolute.uri); 43 await compiler.run(file.absolute.uri);
44 LibraryElement library = 44 var loadedLibraries =
45 await compiler.libraryLoader.loadLibrary(file.absolute.uri); 45 await compiler.libraryLoader.loadLibrary(file.absolute.uri);
46 compiler.processLoadedLibraries(loadedLibraries);
47 var library = loadedLibraries.rootLibrary;
46 JavaScriptBackend backend = compiler.backend; 48 JavaScriptBackend backend = compiler.backend;
47 StringBuffer buffer = new StringBuffer(); 49 StringBuffer buffer = new StringBuffer();
48 Program program = backend.kernelTask.buildProgram(library); 50 Program program = backend.kernelTask.buildProgram(library);
49 new MixinFullResolution().transform(program); 51 new MixinFullResolution().transform(program);
50 new Printer(buffer) 52 new Printer(buffer)
51 .writeLibraryFile(program.mainMethod.enclosingLibrary); 53 .writeLibraryFile(program.mainMethod.enclosingLibrary);
52 String actual = buffer.toString(); 54 String actual = buffer.toString();
53 String expected = 55 String expected =
54 new File('${TESTCASE_DIR}/spec-mode/$name.baseline.txt') 56 new File('${TESTCASE_DIR}/spec-mode/$name.baseline.txt')
55 .readAsStringSync(); 57 .readAsStringSync();
(...skipping 16 matching lines...) Expand all
72 } 74 }
73 75
74 Future<Compiler> newCompiler() async { 76 Future<Compiler> newCompiler() async {
75 var compiler = compilerFor( 77 var compiler = compilerFor(
76 options: [Flags.analyzeOnly, Flags.analyzeAll, Flags.useKernel]); 78 options: [Flags.analyzeOnly, Flags.analyzeAll, Flags.useKernel]);
77 await compiler.setupSdk(); 79 await compiler.setupSdk();
78 80
79 // The visitor no longer enqueues elements that are not reachable from the 81 // The visitor no longer enqueues elements that are not reachable from the
80 // program. The mixin-full resolution transform run by the test expects to 82 // program. The mixin-full resolution transform run by the test expects to
81 // find dart.core::Iterator. 83 // find dart.core::Iterator.
82 var core = await compiler.libraryLoader.loadLibrary(Uri.parse('dart:core')); 84 var loadedLibraries =
85 await compiler.libraryLoader.loadLibrary(Uri.parse('dart:core'));
86 compiler.processLoadedLibraries(loadedLibraries);
87 var core = loadedLibraries.rootLibrary;
83 compiler.startResolution(); 88 compiler.startResolution();
84 var cls = core.implementation.localLookup('Iterator'); 89 var cls = core.implementation.localLookup('Iterator');
85 cls.ensureResolved(compiler.resolution); 90 cls.ensureResolved(compiler.resolution);
86 return compiler; 91 return compiler;
87 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698