OLD | NEW |
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/fasta_codes.dart'; |
7 import 'package:front_end/src/fasta/kernel/utils.dart'; | 7 import 'package:front_end/src/fasta/kernel/utils.dart'; |
8 import 'package:front_end/src/fasta/deprecated_problems.dart' | 8 import 'package:front_end/src/fasta/deprecated_problems.dart' |
9 show deprecated_InputError; | 9 show deprecated_InputError; |
10 import 'package:front_end/src/testing/compiler_common.dart'; | 10 import 'package:front_end/src/testing/compiler_common.dart'; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 expect(printMember.function.body is EmptyStatement, isTrue); | 56 expect(printMember.function.body is EmptyStatement, isTrue); |
57 }); | 57 }); |
58 | 58 |
59 test('compiler requires a main method', () async { | 59 test('compiler requires a main method', () async { |
60 var errors = []; | 60 var errors = []; |
61 var options = new CompilerOptions()..onError = (e) => errors.add(e); | 61 var options = new CompilerOptions()..onError = (e) => errors.add(e); |
62 await compileScript('a() => print("hi");', options: options); | 62 await compileScript('a() => print("hi");', options: options); |
63 expect(errors.first.message, messageMissingMain.message); | 63 expect(errors.first.message, messageMissingMain.message); |
64 }); | 64 }); |
65 | 65 |
| 66 // TODO(ahe): This test is wrong at least with respect to expecting that |
| 67 // [deprecated_InputError] leaks through the API. Furthermore, the default |
| 68 // behavior should be to recover from errors, as this is the most important |
| 69 // use case we have. |
66 test('default error handler throws on errors', () async { | 70 test('default error handler throws on errors', () async { |
67 var options = new CompilerOptions(); | 71 var options = new CompilerOptions(); |
68 var exceptionThrown = false; | 72 var exceptionThrown = false; |
69 try { | 73 try { |
70 await compileScript('a() => print("hi");', options: options); | 74 await compileScript('a() => print("hi");', options: options); |
71 } on deprecated_InputError catch (e) { | 75 } on deprecated_InputError catch (e) { |
72 exceptionThrown = true; | 76 exceptionThrown = true; |
73 expect('${e.error}', contains("Compilation aborted")); | 77 expect('${e.error}', contains("Compilation aborted")); |
74 } | 78 } |
75 expect(exceptionThrown, isTrue); | 79 expect(exceptionThrown, isTrue); |
76 }); | 80 }, skip: true /* Issue 30194 */); |
77 | 81 |
78 test('generated program contains source-info', () async { | 82 test('generated program contains source-info', () async { |
79 var program = await compileScript('a() => print("hi"); main() {}', | 83 var program = await compileScript('a() => print("hi"); main() {}', |
80 fileName: 'a.dart'); | 84 fileName: 'a.dart'); |
81 // Kernel always store an empty '' key in the map, so there is always at | 85 // Kernel always store an empty '' key in the map, so there is always at |
82 // least one. Having more means that source-info is added. | 86 // least one. Having more means that source-info is added. |
83 expect(program.uriToSource.keys.length, greaterThan(1)); | 87 expect(program.uriToSource.keys.length, greaterThan(1)); |
84 expect(program.uriToSource['file:///a/b/c/a.dart'], isNotNull); | 88 expect(program.uriToSource['file:///a/b/c/a.dart'], isNotNull); |
85 }); | 89 }); |
86 | 90 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 checkDCallsC(unitD1); | 210 checkDCallsC(unitD1); |
207 | 211 |
208 var unitD2 = await compileUnit(['d.dart'], sources, | 212 var unitD2 = await compileUnit(['d.dart'], sources, |
209 inputSummaries: ['bc.dill', 'a.dill']); | 213 inputSummaries: ['bc.dill', 'a.dill']); |
210 checkDCallsC(unitD2); | 214 checkDCallsC(unitD2); |
211 }); | 215 }); |
212 | 216 |
213 // TODO(sigmund): add tests with trimming dependencies | 217 // TODO(sigmund): add tests with trimming dependencies |
214 }); | 218 }); |
215 } | 219 } |
OLD | NEW |