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

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

Issue 2980273002: Random improvements in error reporting. (Closed)
Patch Set: rebased 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
« no previous file with comments | « pkg/front_end/messages.yaml ('k') | pkg/front_end/tool/_fasta/generate_messages.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fasta_codes.dart';
6 import 'package:front_end/src/fasta/kernel/utils.dart'; 7 import 'package:front_end/src/fasta/kernel/utils.dart';
7 import 'package:front_end/src/fasta/deprecated_problems.dart' 8 import 'package:front_end/src/fasta/deprecated_problems.dart'
8 show deprecated_InputError; 9 show deprecated_InputError;
9 import 'package:front_end/src/testing/compiler_common.dart'; 10 import 'package:front_end/src/testing/compiler_common.dart';
10 import 'package:kernel/ast.dart'; 11 import 'package:kernel/ast.dart';
11 12
12 import 'package:test/test.dart'; 13 import 'package:test/test.dart';
13 14
14 main() { 15 main() {
15 group('kernelForProgram', () { 16 group('kernelForProgram', () {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 52
52 // Note: summaries created by the SDK today contain empty statements as 53 // Note: summaries created by the SDK today contain empty statements as
53 // method bodies. 54 // method bodies.
54 expect(printMember.function.body is EmptyStatement, isTrue); 55 expect(printMember.function.body is EmptyStatement, isTrue);
55 }); 56 });
56 57
57 test('compiler requires a main method', () async { 58 test('compiler requires a main method', () async {
58 var errors = []; 59 var errors = [];
59 var options = new CompilerOptions()..onError = (e) => errors.add(e); 60 var options = new CompilerOptions()..onError = (e) => errors.add(e);
60 await compileScript('a() => print("hi");', options: options); 61 await compileScript('a() => print("hi");', options: options);
61 // TODO(sigmund): when we expose codes in the public APIs, we should 62 expect(errors.first.message, messageMissingMain.message);
62 // compare the code here and not the message.
63 expect(errors.first.message, contains("No 'main' method found"));
64 }); 63 });
65 64
66 test('default error handler throws on errors', () async { 65 test('default error handler throws on errors', () async {
67 var options = new CompilerOptions(); 66 var options = new CompilerOptions();
68 var exceptionThrown = false; 67 var exceptionThrown = false;
69 try { 68 try {
70 await compileScript('a() => print("hi");', options: options); 69 await compileScript('a() => print("hi");', options: options);
71 } on deprecated_InputError catch (e) { 70 } on deprecated_InputError catch (e) {
72 exceptionThrown = true; 71 exceptionThrown = true;
73 expect('${e.error}', contains("Compilation aborted")); 72 expect('${e.error}', contains("Compilation aborted"));
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 checkDCallsC(unitD1); 205 checkDCallsC(unitD1);
207 206
208 var unitD2 = await compileUnit(['d.dart'], sources, 207 var unitD2 = await compileUnit(['d.dart'], sources,
209 inputSummaries: ['bc.dill', 'a.dill']); 208 inputSummaries: ['bc.dill', 'a.dill']);
210 checkDCallsC(unitD2); 209 checkDCallsC(unitD2);
211 }); 210 });
212 211
213 // TODO(sigmund): add tests with trimming dependencies 212 // TODO(sigmund): add tests with trimming dependencies
214 }); 213 });
215 } 214 }
OLDNEW
« no previous file with comments | « pkg/front_end/messages.yaml ('k') | pkg/front_end/tool/_fasta/generate_messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698