Skip to content

Commit

Permalink
Move test_types_in_equals tests (#4550)
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins authored Jul 13, 2023
1 parent f2a8ccc commit 9b577bb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 43 deletions.
2 changes: 2 additions & 0 deletions test/rules/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import 'sort_constructors_first_test.dart' as sort_constructors_first;
import 'sort_pub_dependencies_test.dart' as sort_pub_dependencies;
import 'sort_unnamed_constructors_first_test.dart'
as sort_unnamed_constructors_first;
import 'test_types_in_equals_test.dart' as test_types_in_equals;
import 'throw_in_finally_test.dart' as throw_in_finally;
import 'tighten_type_of_initializing_formals_test.dart'
as tighten_type_of_initializing_formals;
Expand Down Expand Up @@ -275,6 +276,7 @@ void main() {
sort_constructors_first.main();
sort_pub_dependencies.main();
sort_unnamed_constructors_first.main();
test_types_in_equals.main();
throw_in_finally.main();
tighten_type_of_initializing_formals.main();
type_init_formals.main();
Expand Down
51 changes: 51 additions & 0 deletions test/rules/test_types_in_equals_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2023, 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';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(TestTypesInEqualsTest);
});
}

@reflectiveTest
class TestTypesInEqualsTest extends LintRuleTest {
@override
String get lintRule => 'test_types_in_equals';

test_usesIs() async {
await assertNoDiagnostics(r'''
class C {
int? x;
@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
return other is C && this.x == other.x;
}
}
''');
}

test_doesNotUseIs() async {
await assertDiagnostics(r'''
class C {
int? x;
@override
bool operator ==(Object other) {
C otherC = other as C;
return otherC.x == x;
}
}
''', [
lint(83, 10),
]);
}
}
43 changes: 0 additions & 43 deletions test_data/rules/test_types_in_equals.dart

This file was deleted.

0 comments on commit 9b577bb

Please sign in to comment.