-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for avoid-unrelated-type-assertions rule
- Loading branch information
Denis Bogatirov
committed
Sep 13, 2023
1 parent
322df23
commit 2ea9d5c
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// ignore_for_file: prefer_const_declarations | ||
// ignore_for_file: unnecessary_nullable_for_final_variable_declarations | ||
// ignore_for_file: unused_local_variable | ||
|
||
/// Check the `avoid-unrelated-type-assertions` rule | ||
class Foo {} | ||
|
||
class Bar {} | ||
|
||
class ChildFoo extends Foo {} | ||
|
||
void fun() { | ||
final testString = ''; | ||
final testList = [1, 2, 3]; | ||
final testMap = {'A': 'B'}; | ||
final Foo foo = Foo(); | ||
final childFoo = ChildFoo(); | ||
|
||
// expect_lint: avoid-unrelated-type-assertions | ||
final result = testString is int; | ||
|
||
// expect_lint: avoid-unrelated-type-assertions | ||
final result2 = testList is List<String>; | ||
|
||
// expect_lint: avoid-unrelated-type-assertions | ||
final result3 = foo is Bar; | ||
|
||
// expect_lint: avoid-unrelated-type-assertions | ||
final result4 = childFoo is Bar; | ||
|
||
// expect_lint: avoid-unrelated-type-assertions | ||
final result5 = testMap['A'] is double; | ||
} |