Files
sdk/pkg/linter/test/rules/document_ignores_test.dart
T
pq 36c57a4101 [CQ] [linter] anticipate strict_top_level_inference
Make `main` function returns explicit in anticipation of `strict_top_level_inference`.


Change-Id: I9fe087478b748594e49a586b033412263fda7920
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412383
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
2025-02-26 16:49:22 -08:00

95 lines
1.9 KiB
Dart

// Copyright (c) 2024, 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:test_reflective_loader/test_reflective_loader.dart';
import '../rule_test_support.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(DocumentIgnoresTest);
});
}
@reflectiveTest
class DocumentIgnoresTest extends LintRuleTest {
@override
String get lintRule => LintNames.document_ignores;
test_precedingDeclaration_notDocumented() async {
await assertDiagnostics(
r'''
int x = 0;
// ignore: unused_element
int _y = 0;
''',
[lint(12, 25)],
);
}
test_precedingLine_butIsTrailing_notDocumented() async {
await assertDiagnostics(
r'''
int x = 0; // Text.
// ignore: unused_element
int _y = 0;
''',
[lint(20, 25)],
);
}
test_precedingLine_documented() async {
await assertNoDiagnostics(r'''
// Text.
// ignore: unused_element
int _y = 0;
''');
}
test_precedingLine_ignoreIsTrailing_documented() async {
await assertNoDiagnostics(r'''
// Text.
int _y = 0; // ignore: unused_element
''');
}
test_precedingLine_multiple_documented() async {
await assertNoDiagnostics(r'''
// Text.
// ignore_for_file: unused_element
// Text.
// ignore_for_file: unnecessary_cast
int _y = 0 as int;
''');
}
test_precedingLine_multiple_notDocumented() async {
await assertDiagnostics(
r'''
// Text.
// ignore_for_file: unused_element
// ignore_for_file: unnecessary_cast
int _y = 0 as int;
''',
[lint(45, 36)],
);
}
test_sameComment_comma_documented() async {
await assertNoDiagnostics(r'''
// ignore: unused_element, I need this
int _y = 0;
''');
}
test_sameComment_whitespace_documented() async {
await assertNoDiagnostics(r'''
// ignore: unused_element http://linter-bug
int _y = 0;
''');
}
}