From f7d4d0d85cdfc97e42707914ba6ac72d9ac2cef3 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Thu, 5 May 2022 19:03:35 +0000 Subject: [PATCH] Add failing tests for SortConstructorFirst with comments. Bug: https://github.com/dart-lang/sdk/issues/48966 Change-Id: I2d34a7cc240171759dd331f23118745a5d8ff80e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243841 Commit-Queue: Konstantin Shcheglov Reviewed-by: Brian Wilkerson --- .../fix/sort_constructor_first_test.dart | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/pkg/analysis_server/test/src/services/correction/fix/sort_constructor_first_test.dart b/pkg/analysis_server/test/src/services/correction/fix/sort_constructor_first_test.dart index a1f240ba977..c6a9dc90039 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/sort_constructor_first_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/sort_constructor_first_test.dart @@ -80,6 +80,77 @@ class SortConstructorFirstTest extends FixProcessorLintTest { @override String get lintCode => LintNames.sort_constructors_first; + @FailingTest( + reason: 'The beginToken is the comment, which has no previous token.', + issue: 'https://github.com/dart-lang/sdk/issues/48966', + ) + Future test_hasComment() async { + await resolveTestCode(''' +class A { + void foo() {} + /// comment + A(); +} +'''); + await assertHasFix(''' +class A { + /// comment + A(); + void foo() {} +} +'''); + } + + @FailingTest( + reason: 'The beginToken is the comment, which has no previous token.', + issue: 'https://github.com/dart-lang/sdk/issues/48966', + ) + Future test_hasComment_hasMetadata_afterComment() async { + await resolveTestCode(''' +const a = 0; + +class A { + void foo() {} + /// comment + @a + A(); +} +'''); + await assertHasFix(''' +const a = 0; + +class A { + /// comment + @a + A(); + void foo() {} +} +'''); + } + + Future test_hasComment_hasMetadata_beforeComment() async { + await resolveTestCode(''' +const a = 0; + +class A { + void foo() {} + @a + /// comment + A(); +} +'''); + await assertHasFix(''' +const a = 0; + +class A { + @a + /// comment + A(); + void foo() {} +} +'''); + } + Future test_one_fix() async { await resolveTestCode(''' class A {