Files
sdk/pkg/analyzer/test/generated/static_warning_code_test.dart
T
Sam Rawlins 8432b379e7 Analyzer: Prepare tests for null safety.
Tests that include, for example, a field `int a;` need to be migrated to
something which is both legal in pre-null safety, and in null safety. So no `?`
etc,. Additionally:

* parameters to `main` must be correct,
* new flow analysis may change inference,
* avoid `List()`

Bug: https://github.com/dart-lang/sdk/issues/44666
Change-Id: I77b7c3a6f391953c74824153012c1a537f8bebe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183520
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-02-07 19:45:56 +00:00

109 lines
2.7 KiB
Dart

// Copyright (c) 2014, 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 '../src/dart/resolution/context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(StaticWarningCodeTest);
});
}
@reflectiveTest
class StaticWarningCodeTest extends PubPackageResolutionTest {
// TODO(brianwilkerson) Figure out what to do with the rest of these tests.
// The names do not correspond to diagnostic codes, so it isn't clear what
// they're testing.
test_functionWithoutCall_direct() async {
await assertNoErrorsInCode('''
class A implements Function {
}''');
}
test_functionWithoutCall_direct_typeAlias() async {
await assertNoErrorsInCode('''
class M {}
class A = Object with M implements Function;''');
}
test_functionWithoutCall_indirect_extends() async {
await assertNoErrorsInCode('''
abstract class A implements Function {
}
class B extends A {
}''');
}
test_functionWithoutCall_indirect_extends_typeAlias() async {
await assertNoErrorsInCode('''
abstract class A implements Function {}
class M {}
class B = A with M;''');
}
test_functionWithoutCall_indirect_implements() async {
await assertNoErrorsInCode('''
abstract class A implements Function {
}
class B implements A {
}''');
}
test_functionWithoutCall_indirect_implements_typeAlias() async {
await assertNoErrorsInCode('''
abstract class A implements Function {}
class M {}
class B = Object with M implements A;''');
}
test_functionWithoutCall_mixin_implements() async {
await assertNoErrorsInCode('''
abstract class A implements Function {}
class B extends Object with A {}''');
}
test_functionWithoutCall_mixin_implements_typeAlias() async {
await assertNoErrorsInCode('''
abstract class A implements Function {}
class B = Object with A;''');
}
test_nonAbstractClassInheritsAbstractMemberOne_ensureCorrectFunctionSubtypeIsUsedInImplementation() async {
// 15028
await assertErrorsInCode('''
class C {
foo(int x) => x;
}
abstract class D {
foo(x, [y]);
}
class E extends C implements D {}''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 73, 1),
]);
}
test_typePromotion_functionType_arg_InterToDyn() async {
await assertNoErrorsInCode('''
typedef FuncDyn(x);
typedef FuncA(A a);
class A {}
class B {}
f(FuncA f) {
if (f is FuncDyn) {
f(new B());
}
}''');
}
test_voidReturnForGetter() async {
await assertNoErrorsInCode('''
class S {
void get value {}
}''');
}
}