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

Side by Side Diff: pkg/front_end/test/kernel_generator_test.dart

Issue 2982093003: Unifying compiler context (Closed)
Patch Set: revert change to kernel-service.dart Created 3 years, 5 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:front_end/front_end.dart'; 5 import 'package:front_end/front_end.dart';
6 import 'package:front_end/src/fasta/kernel/utils.dart'; 6 import 'package:front_end/src/fasta/kernel/utils.dart';
7 import 'package:front_end/src/fasta/deprecated_problems.dart'
8 show deprecated_InputError;
7 import 'package:front_end/src/testing/compiler_common.dart'; 9 import 'package:front_end/src/testing/compiler_common.dart';
8 import 'package:kernel/ast.dart'; 10 import 'package:kernel/ast.dart';
9 11
10 import 'package:test/test.dart'; 12 import 'package:test/test.dart';
11 13
12 main() { 14 main() {
13 group('kernelForProgram', () { 15 group('kernelForProgram', () {
14 test('compiler fails if it cannot find sdk sources', () async { 16 test('compiler fails if it cannot find sdk sources', () async {
15 var errors = []; 17 var errors = [];
16 var options = new CompilerOptions() 18 var options = new CompilerOptions()
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 56
55 test('compiler requires a main method', () async { 57 test('compiler requires a main method', () async {
56 var errors = []; 58 var errors = [];
57 var options = new CompilerOptions()..onError = (e) => errors.add(e); 59 var options = new CompilerOptions()..onError = (e) => errors.add(e);
58 await compileScript('a() => print("hi");', options: options); 60 await compileScript('a() => print("hi");', options: options);
59 // TODO(sigmund): when we expose codes in the public APIs, we should 61 // TODO(sigmund): when we expose codes in the public APIs, we should
60 // compare the code here and not the message. 62 // compare the code here and not the message.
61 expect(errors.first.message, contains("No 'main' method found")); 63 expect(errors.first.message, contains("No 'main' method found"));
62 }); 64 });
63 65
64 test('default error handler throws', () async { 66 test('default error handler throws on errors', () async {
67 var options = new CompilerOptions();
65 var exceptionThrown = false; 68 var exceptionThrown = false;
66 try { 69 try {
67 await compileScript('a() => print("hi");'); 70 await compileScript('a() => print("hi");', options: options);
68 } on CompilationError catch (e) { 71 } on deprecated_InputError catch (e) {
69 exceptionThrown = true; 72 exceptionThrown = true;
70 expect(e.message, contains("No 'main' method found")); 73 expect('${e.error}', contains("Compilation aborted"));
71 } 74 }
72 expect(exceptionThrown, isTrue); 75 expect(exceptionThrown, isTrue);
73 }); 76 });
74 77
75 test('generated program contains source-info', () async { 78 test('generated program contains source-info', () async {
76 var program = await compileScript('a() => print("hi"); main() {}', 79 var program = await compileScript('a() => print("hi"); main() {}',
77 fileName: 'a.dart'); 80 fileName: 'a.dart');
78 // Kernel always store an empty '' key in the map, so there is always at 81 // Kernel always store an empty '' key in the map, so there is always at
79 // least one. Having more means that source-info is added. 82 // least one. Having more means that source-info is added.
80 expect(program.uriToSource.keys.length, greaterThan(1)); 83 expect(program.uriToSource.keys.length, greaterThan(1));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 checkDCallsC(unitD1); 206 checkDCallsC(unitD1);
204 207
205 var unitD2 = await compileUnit(['d.dart'], sources, 208 var unitD2 = await compileUnit(['d.dart'], sources,
206 inputSummaries: ['bc.dill', 'a.dill']); 209 inputSummaries: ['bc.dill', 'a.dill']);
207 checkDCallsC(unitD2); 210 checkDCallsC(unitD2);
208 }); 211 });
209 212
210 // TODO(sigmund): add tests with trimming dependencies 213 // TODO(sigmund): add tests with trimming dependencies
211 }); 214 });
212 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698