From fe95b58b2972e5e5c795d158fbdb2451f09fce20 Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Mon, 24 Jul 2023 11:21:04 -0700 Subject: [PATCH] migrate `exhaustive_cases` integration test (dart-lang/linter#4607) * migrate `exhaustive_cases` integration test * whoops --- test/integration/exhaustive_cases.dart | 32 ------------------- test/integration_test.dart | 2 -- test/rules/exhaustive_cases_test.dart | 29 +++++++++++++++++ test_data/integration/exhaustive_cases/a.dart | 16 ---------- test_data/integration/exhaustive_cases/e.dart | 13 -------- 5 files changed, 29 insertions(+), 63 deletions(-) delete mode 100644 test/integration/exhaustive_cases.dart delete mode 100644 test_data/integration/exhaustive_cases/a.dart delete mode 100644 test_data/integration/exhaustive_cases/e.dart diff --git a/test/integration/exhaustive_cases.dart b/test/integration/exhaustive_cases.dart deleted file mode 100644 index 75829a3e713b..000000000000 --- a/test/integration/exhaustive_cases.dart +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2020, 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/lint/io.dart'; -import 'package:analyzer/src/lint/linter.dart'; -import 'package:linter/src/analyzer.dart'; -import 'package:linter/src/cli.dart' as cli; -import 'package:test/test.dart'; - -import '../mocks.dart'; -import '../test_constants.dart'; - -void main() { - group('exhaustive_cases', () { - var currentOut = outSink; - var collectingOut = CollectingSink(); - setUp(() => outSink = collectingOut); - tearDown(() { - collectingOut.buffer.clear(); - outSink = currentOut; - }); - test('exhaustive_cases', () async { - await cli.runLinter([ - '$integrationTestDir/exhaustive_cases', - '--rules=exhaustive_cases', - ], LinterOptions()); - expect(collectingOut.trim(), - contains('2 files analyzed, 1 issue found, in')); - }); - }); -} diff --git a/test/integration_test.dart b/test/integration_test.dart index bd3652852f28..baee4023a63b 100644 --- a/test/integration_test.dart +++ b/test/integration_test.dart @@ -17,7 +17,6 @@ import '../test_data/rules/experiments/experiments.dart'; import 'integration/avoid_web_libraries_in_flutter.dart' as avoid_web_libraries_in_flutter; import 'integration/close_sinks.dart' as close_sinks; -import 'integration/exhaustive_cases.dart' as exhaustive_cases; import 'integration/public_member_api_docs.dart' as public_member_api_docs; import 'integration/use_build_context_synchronously.dart' as use_build_context_synchronously; @@ -126,7 +125,6 @@ void coreTests() { void ruleTests() { group('rule', () { - exhaustive_cases.main(); avoid_web_libraries_in_flutter.main(); close_sinks.main(); public_member_api_docs.main(); diff --git a/test/rules/exhaustive_cases_test.dart b/test/rules/exhaustive_cases_test.dart index 837b78d31a8d..a0f9e5a71566 100644 --- a/test/rules/exhaustive_cases_test.dart +++ b/test/rules/exhaustive_cases_test.dart @@ -165,6 +165,35 @@ void okParenthesized(E e) { '''); } + test_enumLike_prefixed() async { + newFile('$testPackageLibPath/e.dart', ''' +class E { + final int i; + const E._(this.i); + + static const e = E._(1); + static const f = E._(2); + static const g = E._(3); +} +'''); + + await assertDiagnostics(r''' +import 'e.dart' as prefixed; + +void e(prefixed.E e) { + switch(e) { + case prefixed.E.e : + print('e'); + break; + case prefixed.E.f : + print('e'); + } +} +''', [ + lint(55, 9), + ]); + } + test_notEnumLike_ok() async { await assertNoDiagnostics(r''' class TooFew { diff --git a/test_data/integration/exhaustive_cases/a.dart b/test_data/integration/exhaustive_cases/a.dart deleted file mode 100644 index 3e5c6279701b..000000000000 --- a/test_data/integration/exhaustive_cases/a.dart +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2020, 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 'e.dart' as prefixed; - -void e(prefixed.E e) { - // Missing case. - switch(e) { // LINT - case prefixed.E.e : - print('e'); - break; - case prefixed.E.f : - print('e'); - } -} diff --git a/test_data/integration/exhaustive_cases/e.dart b/test_data/integration/exhaustive_cases/e.dart deleted file mode 100644 index 097db1e7e874..000000000000 --- a/test_data/integration/exhaustive_cases/e.dart +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2020, 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. - -// Enum-like -class E { - final int i; - const E._(this.i); - - static const e = E._(1); - static const f = E._(2); - static const g = E._(3); -}