Files
sdk/pkg/linter/test/rules/package_api_docs_test.dart
T
Parker Lougheed a409a1c07d [analyzer/linter] Use shared enumeration for lint names
This helps to avoid any accidental mispellings, enables find usages, and potentially makes future renames easier.

The primary goal is to make future work in https://github.com/dart-lang/sdk/issues/56835 easier.

Change-Id: I684630a4d6cb145031de0dabc221f247246ea00c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-03 21:36:49 +00:00

69 lines
1.5 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:analyzer/src/error/analyzer_error_code.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../rule_test_support.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(PackageApiDocsTest);
});
}
@reflectiveTest
class PackageApiDocsTest extends LintRuleTest {
@override
List<AnalyzerErrorCode> get ignoredErrorCodes => [WarningCode.UNUSED_ELEMENT];
@override
String get lintRule => LintNames.package_api_docs;
test_privateClass() async {
await assertNoDiagnostics(r'''
class _Bar {}
''');
}
@FailingTest(reason: 'fix API Model to treat tests specially')
test_publicClass() async {
await assertDiagnostics(r'''
class Foo {}
''', [
lint(6, 3),
]);
}
test_publicMember_ofPrivateClass() async {
await assertNoDiagnostics(r'''
class _C {
int m() => 42;
}
''');
}
@FailingTest(reason: 'fix API Model to treat tests specially')
test_publicMember_ofPublicClass() async {
await assertDiagnostics(r'''
/// Documented.
class Foo {
int foo() => 42;
}
''', [
lint(34, 3),
]);
}
test_publicMember_ofPublicClass_documented() async {
await assertNoDiagnostics(r'''
/// Documented.
class Foo {
/// Documented.
int foo() => 42;
}
''');
}
}