blob: e108ef799a3c79c0e1948f5ae0fa78b625005c59 [file] [log] [blame]
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/error/codes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(NonTypeInCatchClauseTest);
});
}
@reflectiveTest
class NonTypeInCatchClauseTest extends DriverResolutionTest {
test_notDefined() async {
await assertErrorsInCode('''
f() {
try {
} on T catch (e) {
}
}
''', [
error(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, 21, 1),
error(HintCode.UNUSED_CATCH_CLAUSE, 30, 1),
]);
}
test_notType() async {
await assertErrorsInCode('''
var T = 0;
f() {
try {
} on T catch (e) {
}
}
''', [
error(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, 32, 1),
error(HintCode.UNUSED_CATCH_CLAUSE, 41, 1),
]);
}
}