Skip to content

Commit

Permalink
linter: move cast_nullable_to_non_nullable tests
Browse files Browse the repository at this point in the history
Change-Id: I5bd5482108b9c0bb29936819ef4151d6b947a4b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366080
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
  • Loading branch information
srawlins authored and Commit Queue committed May 13, 2024
1 parent 299ddd0 commit a9c2f1b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 34 deletions.
29 changes: 28 additions & 1 deletion pkg/linter/test/rules/cast_nullable_to_non_nullable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,23 @@ class CastNullableToNonNullableTest extends LintRuleTest {
@override
String get lintRule => 'cast_nullable_to_non_nullable';

test_castNullable() async {
test_castDynamic_toNonNullable() async {
await assertNoDiagnostics(r'''
void f(dynamic a) {
a as String;
}
''');
}

test_castDynamic_toNullable() async {
await assertNoDiagnostics(r'''
void f(dynamic a) {
a as String?;
}
''');
}

test_castNullable_toNonNullable() async {
await assertDiagnostics(r'''
String? s;
var a = s as String;
Expand All @@ -26,6 +42,17 @@ var a = s as String;
]);
}

test_castNullable_toNullable() async {
await assertNoDiagnostics(r'''
class A {}
class B extends A {}
void f(A? a) {
a as B?;
}
''');
}

test_castNullable_unresolvedType() async {
await assertDiagnostics(r'''
Undefined? s;
Expand Down
33 changes: 0 additions & 33 deletions pkg/linter/test_data/rules/cast_nullable_to_non_nullable.dart

This file was deleted.

0 comments on commit a9c2f1b

Please sign in to comment.