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

Side by Side Diff: tests/compiler/dart2js/kernel/class_hierarchy_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 class 5 /// Test that the dart2js copy of [KernelVisitor] generates the expected class
6 /// hierarchy. 6 /// hierarchy.
7 7
8 import 'package:compiler/src/commandline_options.dart' show Flags;
8 import 'package:compiler/src/compiler.dart' show Compiler; 9 import 'package:compiler/src/compiler.dart' show Compiler;
9 import 'package:compiler/src/elements/elements.dart'; 10 import 'package:compiler/src/elements/elements.dart';
10 import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend; 11 import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend;
11 import 'package:compiler/src/commandline_options.dart' show Flags; 12 import 'package:compiler/src/library_loader.dart' show LoadedLibraries;
12 import 'package:kernel/ast.dart' as ir; 13 import 'package:kernel/ast.dart' as ir;
13 import 'package:kernel/class_hierarchy.dart'; 14 import 'package:kernel/class_hierarchy.dart';
14 import 'package:test/test.dart'; 15 import 'package:test/test.dart';
15 16
16 import '../memory_compiler.dart'; 17 import '../memory_compiler.dart';
17 18
18 main(List<String> arguments) { 19 main(List<String> arguments) {
19 Compiler compiler = compilerFor(memorySourceFiles: { 20 Compiler compiler = compilerFor(memorySourceFiles: {
20 'main.dart': ''' 21 'main.dart': '''
21 class S { 22 class S {
22 sMethod() {} 23 sMethod() {}
23 } 24 }
24 class M { 25 class M {
25 mMethod() {} 26 mMethod() {}
26 } 27 }
27 class C extends S with M { 28 class C extends S with M {
28 cMethod() {} 29 cMethod() {}
29 } 30 }
30 main() {} 31 main() {}
31 ''' 32 '''
32 }, options: [ 33 }, options: [
33 Flags.analyzeOnly, 34 Flags.analyzeOnly,
34 Flags.analyzeAll, 35 Flags.analyzeAll,
35 Flags.useKernel 36 Flags.useKernel
36 ]); 37 ]);
37 test('mixin', () async { 38 test('mixin', () async {
38 Uri mainUri = Uri.parse('memory:main.dart'); 39 Uri mainUri = Uri.parse('memory:main.dart');
39 await compiler.run(mainUri); 40 await compiler.run(mainUri);
40 LibraryElement library = await compiler.libraryLoader.loadLibrary(mainUri); 41 LoadedLibraries libraries =
42 await compiler.libraryLoader.loadLibrary(mainUri);
43 compiler.processLoadedLibraries(libraries);
41 JavaScriptBackend backend = compiler.backend; 44 JavaScriptBackend backend = compiler.backend;
42 ir.Program program = backend.kernelTask.buildProgram(library); 45 ir.Program program = backend.kernelTask.buildProgram(libraries.rootLibrary);
43 ClassHierarchy hierarchy = new ClassHierarchy(program); 46 ClassHierarchy hierarchy = new ClassHierarchy(program);
44 47
45 ir.Class getClass(String name) { 48 ir.Class getClass(String name) {
46 for (ir.Class cls in hierarchy.classes) { 49 for (ir.Class cls in hierarchy.classes) {
47 if (cls.enclosingLibrary.importUri == mainUri && cls.name == name) { 50 if (cls.enclosingLibrary.importUri == mainUri && cls.name == name) {
48 if (arguments.contains('-v')) { 51 if (arguments.contains('-v')) {
49 print('$cls'); 52 print('$cls');
50 print(' dispatch targets:'); 53 print(' dispatch targets:');
51 hierarchy 54 hierarchy
52 .getDispatchTargets(cls) 55 .getDispatchTargets(cls)
(...skipping 15 matching lines...) Expand all
68 hierarchy.getDispatchTarget(subClass, member.name), equals(member), 71 hierarchy.getDispatchTarget(subClass, member.name), equals(member),
69 reason: 'Unexpected dispatch target for ${member.name} ' 72 reason: 'Unexpected dispatch target for ${member.name} '
70 'in $subClass'); 73 'in $subClass');
71 } 74 }
72 } 75 }
73 76
74 checkInheritance(classS, classC); 77 checkInheritance(classS, classC);
75 checkInheritance(classM, classC); 78 checkInheritance(classM, classC);
76 }); 79 });
77 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698