Skip to content

Commit

Permalink
linter: Move camel_case_types tests
Browse files Browse the repository at this point in the history
Change-Id: I106c2238f4ecb596809e195ef7b1f00cc47a95d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366061
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
  • Loading branch information
srawlins authored and Commit Queue committed May 13, 2024
1 parent 5547884 commit f99bebc
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 50 deletions.
130 changes: 122 additions & 8 deletions pkg/linter/test/rules/camel_case_types_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class CamelCaseTypesTest extends LintRuleTest {
newFile('$testPackageLibPath/a.dart', r'''
import augment 'test.dart';
class a { }
class a {}
''');

await assertNoDiagnostics(r'''
augment library 'a.dart';
augment class a { }
augment class a {}
''');
}

Expand All @@ -53,27 +53,94 @@ augment enum e {
newFile('$testPackageLibPath/a.dart', r'''
import augment 'test.dart';
extension type et(int i) { }
extension type et(int i) {}
''');

await assertNoDiagnostics(r'''
augment library 'a.dart';
augment extension type et(int i) { }
augment extension type et(int i) {}
''');
}

test_augmentationMixin_lowerCase() async {
newFile('$testPackageLibPath/a.dart', r'''
import augment 'test.dart';
mixin m { }
mixin m {}
''');

await assertNoDiagnostics(r'''
augment library 'a.dart';
augment mixin m { }
augment mixin m {}
''');
}

test_class_dollar_thenUpperCamel() async {
await assertNoDiagnostics(r'''
class $FooBar
{}
''');
}

test_class_lowerCamel() async {
await assertDiagnostics(r'''
class fooBar {}
''', [
lint(6, 6),
]);
}

test_class_upperCamel() async {
await assertNoDiagnostics(r'''
class FooBar {}
''');
}

test_class_upperCamel_private() async {
await assertNoDiagnostics(r'''
class _Foo {} // ignore: unused_element
''');
}

test_class_upperCamel_withDollar() async {
await assertNoDiagnostics(r'''
class Foo$Bar {}
''');
}

test_class_upperCase1() async {
await assertNoDiagnostics(r'''
class A {}
''');
}

test_class_upperCase2() async {
await assertNoDiagnostics(r'''
class AA {}
''');
}

test_class_upperSnake() async {
await assertDiagnostics(r'''
class Foo_Bar {}
''', [
lint(6, 7),
]);
}

test_enum_lowerCamel() async {
await assertDiagnostics(r'''
enum foooBar { a }
''', [
lint(5, 7),
]);
}

test_enum_upperCamel() async {
await assertNoDiagnostics(r'''
enum FoooBar { a }
''');
}

Expand All @@ -95,17 +162,64 @@ extension type FooBar(int i) {}

test_macroClass_lowerCase() async {
await assertDiagnostics(r'''
macro class a { }
macro class a {}
''', [
lint(12, 1),
]);
}

test_mixin_lowerCase() async {
await assertDiagnostics(r'''
mixin m { }
mixin m {}
''', [
lint(6, 1),
]);
}

test_mixinApplication_lower() async {
await assertDiagnostics(r'''
mixin M {}
class c = Object with M;
''', [
lint(17, 1),
]);
}

test_typedef_newFormat_lower() async {
await assertDiagnostics(r'''
typedef f = void Function();
''', [
lint(8, 1),
]);
}

test_typedef_newFormat_lowerCamel() async {
await assertDiagnostics(r'''
class Foo {}
typedef foo = Foo;
''', [
lint(21, 3),
]);
}

test_typedef_newFormat_upperCamel() async {
await assertNoDiagnostics(r'''
class Foo {}
typedef F = Foo;
''');
}

test_typedef_oldFormat_lowerCamel() async {
await assertDiagnostics(r'''
typedef bool predicate();
''', [
lint(13, 9),
]);
}

test_typedef_oldFormat_upperCamel() async {
await assertNoDiagnostics(r'''
typedef bool Predicate();
''');
}
}
42 changes: 0 additions & 42 deletions pkg/linter/test_data/rules/camel_case_types.dart

This file was deleted.

0 comments on commit f99bebc

Please sign in to comment.