mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:18:13 +00:00
[dart2js] Allow multiple errors in native_test
native_test is set up so that it validates only one error per static error. This CL allows multiple errors to be reported and validates that all are reported. Change-Id: I97e9abbfbd8273c0c436e44d08f5768eea3f7785 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157663 Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
parent
5bd3e5a63f
commit
57a522eaaf
|
@ -138,8 +138,8 @@ main() {
|
|||
'54',
|
||||
]);
|
||||
|
||||
await runTest('tests/dart2js_2/native/native_test.dart',
|
||||
'tests/dart2js_2/native/', {
|
||||
await runTest(
|
||||
'tests/dart2js_2/native/native_test.dart', 'tests/dart2js_2/native/', {
|
||||
'Class': Kind.regular,
|
||||
'NativeClass': Kind.native,
|
||||
'topLevelField': Kind.regular,
|
||||
|
@ -226,7 +226,10 @@ runTest(String fileName, String location, Map<String, Kind> expectations,
|
|||
subTest.lines[lineIndex] = line;
|
||||
int commentIndex = prefix.indexOf('// ');
|
||||
if (commentIndex != -1) {
|
||||
subTest.expectedError = prefix.substring(commentIndex + 3).trim();
|
||||
String combinedErrors = prefix.substring(commentIndex + 3);
|
||||
for (String error in combinedErrors.split(',')) {
|
||||
subTest.expectedErrors.add(error.trim());
|
||||
}
|
||||
}
|
||||
commonLines.add('');
|
||||
} else {
|
||||
|
@ -325,17 +328,20 @@ runNegativeTest(
|
|||
entryPoint: entryPoint,
|
||||
memorySourceFiles: sources,
|
||||
diagnosticHandler: collector);
|
||||
Expect.isFalse(result.isSuccess, "Expected compile time error for\n$subTest");
|
||||
Expect.equals(
|
||||
1, collector.errors.length, "Expected compile time error for\n$subTest");
|
||||
Expect.equals(
|
||||
'MessageKind.${subTest.expectedError}',
|
||||
collector.errors.first.messageKind.toString(),
|
||||
"Unexpected compile time error for\n$subTest");
|
||||
Expect.isFalse(result.isSuccess,
|
||||
"Expected compile time error(s) for\n$subTest");
|
||||
List<String> expected =
|
||||
subTest.expectedErrors.map((error) => 'MessageKind.' + error).toList();
|
||||
List<String> actual =
|
||||
collector.errors.map((error) => error.messageKind.toString()).toList();
|
||||
expected.sort();
|
||||
actual.sort();
|
||||
Expect.listEquals(expected, actual,
|
||||
"Unexpected compile time error(s) for\n$subTest");
|
||||
}
|
||||
|
||||
class SubTest {
|
||||
String expectedError;
|
||||
List<String> expectedErrors = [];
|
||||
final Map<int, String> lines = <int, String>{};
|
||||
|
||||
String generateCode(List<String> commonLines) {
|
||||
|
|
Loading…
Reference in a new issue