Skip to content

Commit 205437e

Browse files
pqCommit Queue
authored andcommitted
[lint] more tests for unnecessary_underscores
Change-Id: I13919d11d3f782d3c80682025113d0cea9f27a30 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403440 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent a546836 commit 205437e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pkg/linter/test/rules/unnecessary_underscores_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ class UnnecessaryUnderscoresTest extends LintRuleTest {
1717
@override
1818
String get lintRule => 'unnecessary_underscores';
1919

20+
test_enum_field_unused() async {
21+
await assertDiagnostics(r'''
22+
enum E {
23+
__,
24+
}
25+
''', [
26+
// No lint.
27+
error(WarningCode.UNUSED_FIELD, 11, 2),
28+
]);
29+
}
30+
2031
test_field_unused() async {
2132
await assertDiagnostics(r'''
2233
class C {
@@ -89,6 +100,30 @@ void f() {
89100
''');
90101
}
91102

103+
test_localFunction_parameter_unused() async {
104+
await assertDiagnostics(r'''
105+
void f() {
106+
g(int __) {}
107+
}
108+
''', [
109+
error(WarningCode.UNUSED_ELEMENT, 13, 1),
110+
lint(19, 2),
111+
]);
112+
}
113+
114+
test_localFunction_parameter_used() async {
115+
await assertDiagnostics(r'''
116+
void f() {
117+
g(int __) {
118+
print(__);
119+
}
120+
}
121+
''', [
122+
// No lint.
123+
error(WarningCode.UNUSED_ELEMENT, 13, 1),
124+
]);
125+
}
126+
92127
test_localFunction_unused() async {
93128
await assertDiagnostics(r'''
94129
f() {

0 commit comments

Comments
 (0)