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

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

Issue 1409803006: Rename apiimpl.Compiler to CompilerImpl. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix long lines Created 5 years, 1 month 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 CPS IR code generator generates source information. 5 // Test that the CPS IR code generator generates source information.
6 6
7 library source_information_tests; 7 library source_information_tests;
8 8
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
11 import 'package:compiler/src/apiimpl.dart' 11 import 'package:compiler/src/apiimpl.dart'
12 show Compiler; 12 show CompilerImpl;
13 import 'memory_compiler.dart'; 13 import 'memory_compiler.dart';
14 import 'package:compiler/src/cps_ir/cps_ir_nodes.dart' as ir; 14 import 'package:compiler/src/cps_ir/cps_ir_nodes.dart' as ir;
15 import 'package:compiler/src/cps_ir/cps_ir_nodes_sexpr.dart' as ir; 15 import 'package:compiler/src/cps_ir/cps_ir_nodes_sexpr.dart' as ir;
16 import 'package:compiler/src/js/js.dart' as js; 16 import 'package:compiler/src/js/js.dart' as js;
17 import 'package:compiler/src/elements/elements.dart'; 17 import 'package:compiler/src/elements/elements.dart';
18 18
19 const String TEST_MAIN_FILE = 'test.dart'; 19 const String TEST_MAIN_FILE = 'test.dart';
20 20
21 class TestEntry { 21 class TestEntry {
22 final String source; 22 final String source;
23 final List<String> expectation; 23 final List<String> expectation;
24 final String elementName; 24 final String elementName;
25 25
26 const TestEntry(this.source, this.expectation) 26 const TestEntry(this.source, this.expectation)
27 : elementName = null; 27 : elementName = null;
28 28
29 const TestEntry.forMethod(this.elementName, 29 const TestEntry.forMethod(this.elementName,
30 this.source, this.expectation); 30 this.source, this.expectation);
31 } 31 }
32 32
33 String formatTest(Map test) { 33 String formatTest(Map test) {
34 return test[TEST_MAIN_FILE]; 34 return test[TEST_MAIN_FILE];
35 } 35 }
36 36
37 js.Node getCodeForMain(Compiler compiler) { 37 js.Node getCodeForMain(CompilerImpl compiler) {
38 Element mainFunction = compiler.mainFunction; 38 Element mainFunction = compiler.mainFunction;
39 return compiler.enqueuer.codegen.generatedCode[mainFunction]; 39 return compiler.enqueuer.codegen.generatedCode[mainFunction];
40 } 40 }
41 41
42 js.Node getJsNodeForElement(Compiler compiler, Element element) { 42 js.Node getJsNodeForElement(CompilerImpl compiler, Element element) {
43 return compiler.enqueuer.codegen.generatedCode[element]; 43 return compiler.enqueuer.codegen.generatedCode[element];
44 } 44 }
45 45
46 String getCodeForMethod(Compiler compiler, String name) { 46 String getCodeForMethod(CompilerImpl compiler, String name) {
47 Element foundElement; 47 Element foundElement;
48 for (Element element in compiler.enqueuer.codegen.generatedCode.keys) { 48 for (Element element in compiler.enqueuer.codegen.generatedCode.keys) {
49 if (element.toString() == name) { 49 if (element.toString() == name) {
50 if (foundElement != null) { 50 if (foundElement != null) {
51 Expect.fail('Multiple compiled elements are called $name'); 51 Expect.fail('Multiple compiled elements are called $name');
52 } 52 }
53 foundElement = element; 53 foundElement = element;
54 } 54 }
55 } 55 }
56 56
57 if (foundElement == null) { 57 if (foundElement == null) {
58 Expect.fail('There is no compiled element called $name'); 58 Expect.fail('There is no compiled element called $name');
59 } 59 }
60 60
61 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement]; 61 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement];
62 return js.prettyPrint(ast, compiler).getText(); 62 return js.prettyPrint(ast, compiler).getText();
63 } 63 }
64 64
65 runTests(List<TestEntry> tests) { 65 runTests(List<TestEntry> tests) {
66 for (TestEntry test in tests) { 66 for (TestEntry test in tests) {
67 Map files = {TEST_MAIN_FILE: test.source}; 67 Map files = {TEST_MAIN_FILE: test.source};
68 asyncTest(() { 68 asyncTest(() {
69 Compiler compiler = compilerFor( 69 CompilerImpl compiler = compilerFor(
70 memorySourceFiles: files, options: <String>['--use-cps-ir']); 70 memorySourceFiles: files, options: <String>['--use-cps-ir']);
71 ir.FunctionDefinition irNodeForMain; 71 ir.FunctionDefinition irNodeForMain;
72 72
73 void cacheIrNodeForMain(Element function, ir.FunctionDefinition irNode) { 73 void cacheIrNodeForMain(Element function, ir.FunctionDefinition irNode) {
74 if (function == compiler.mainFunction) { 74 if (function == compiler.mainFunction) {
75 assert(irNodeForMain == null); 75 assert(irNodeForMain == null);
76 irNodeForMain = irNode; 76 irNodeForMain = irNode;
77 } 77 }
78 } 78 }
79 79
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 print('Hello'); 141 print('Hello');
142 print('World'); 142 print('World');
143 } 143 }
144 """, const ['memory:test.dart:[2,3]', 144 """, const ['memory:test.dart:[2,3]',
145 'memory:test.dart:[3,3]']), 145 'memory:test.dart:[3,3]']),
146 ]; 146 ];
147 147
148 void main() { 148 void main() {
149 runTests(tests); 149 runTests(tests);
150 } 150 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/js_backend_cps_ir.dart ('k') | tests/compiler/dart2js/library_resolution_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698