[M] Change in dart/sdk[main]: linter: Move avoid_multiple_declarations_per_line tests

2 views
Skip to first unread message

CBuild (Gerrit)

unread,
Oct 2, 2023, 11:02:12 AM10/2/23
to Samuel Rawlins, rev...@dartlang.org, Commit Queue

go/dart-cbuild result: SUCCESS

Details: https://goto.google.com/dart-cbuild/find/4cbf7d587fff8c87c824ac3db5126d70a4c693a8

View Change

    To view, visit change 329140. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: sdk
    Gerrit-Branch: main
    Gerrit-Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
    Gerrit-Change-Number: 329140
    Gerrit-PatchSet: 1
    Gerrit-Owner: Samuel Rawlins <sraw...@google.com>
    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
    Gerrit-Comment-Date: Mon, 02 Oct 2023 15:02:07 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No

    Samuel Rawlins (Gerrit)

    unread,
    Oct 4, 2023, 11:03:27 PM10/4/23
    to Phil Quitslund, rev...@dartlang.org

    Attention is currently required from: Phil Quitslund.

    Samuel Rawlins would like Phil Quitslund to review this change.

    View Change

    linter: Move avoid_multiple_declarations_per_line tests

    Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
    ---
    M pkg/linter/test/rules/all.dart
    A pkg/linter/test/rules/avoid_multiple_declarations_per_line_test.dart
    D pkg/linter/test_data/rules/avoid_multiple_declarations_per_line.dart
    3 files changed, 99 insertions(+), 59 deletions(-)

    diff --git a/pkg/linter/test/rules/all.dart b/pkg/linter/test/rules/all.dart
    index adc8b30..3fe18c4 100644
    --- a/pkg/linter/test/rules/all.dart
    +++ b/pkg/linter/test/rules/all.dart
    @@ -16,6 +16,8 @@
    import 'avoid_function_literals_in_foreach_calls_test.dart'
    as avoid_function_literals_in_foreach_calls;
    import 'avoid_init_to_null_test.dart' as avoid_init_to_null;
    +import 'avoid_multiple_declarations_per_line_test.dart'
    + as avoid_multiple_declarations_per_line;
    import 'avoid_positional_boolean_parameters_test.dart'
    as avoid_positional_boolean_parameters;
    import 'avoid_print_test.dart' as avoid_print;
    @@ -259,6 +261,7 @@
    avoid_final_parameters.main();
    avoid_function_literals_in_foreach_calls.main();
    avoid_init_to_null.main();
    + avoid_multiple_declarations_per_line.main();
    avoid_positional_boolean_parameters.main();
    avoid_print.main();
    avoid_private_typedef_functions.main();
    diff --git a/pkg/linter/test/rules/avoid_multiple_declarations_per_line_test.dart b/pkg/linter/test/rules/avoid_multiple_declarations_per_line_test.dart
    new file mode 100644
    index 0000000..251bd64
    --- /dev/null
    +++ b/pkg/linter/test/rules/avoid_multiple_declarations_per_line_test.dart
    @@ -0,0 +1,96 @@
    +// 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(AvoidMultipleDeclarationsPerLineTest);
    + });
    +}
    +
    +@reflectiveTest
    +class AvoidMultipleDeclarationsPerLineTest extends LintRuleTest {
    + @override
    + String get lintRule => 'avoid_multiple_declarations_per_line';
    +
    + test_extensionField_multiple() async {
    + await assertDiagnostics(r'''
    +extension E on Object {
    + static String? a, b, c;
    +}
    +''', [
    + lint(44, 1),
    + ]);
    + }
    +
    + test_extensionField_single() async {
    + await assertNoDiagnostics(r'''
    +extension E on Object {
    + static String? a;
    +}
    +''');
    + }
    +
    + test_field_multiple() async {
    + await assertDiagnostics(r'''
    +class C {
    + String? a, b, c;
    +}
    +''', [
    + lint(23, 1),
    + ]);
    + }
    +
    + test_field_single() async {
    + await assertNoDiagnostics(r'''
    +class C {
    + String? a;
    +}
    +''');
    + }
    +
    + test_forLoop_multiple() async {
    + await assertNoDiagnostics(r'''
    +// See https://github.com/dart-lang/linter/issues/2543.
    +void f() {
    + for (var i = 0, j = 0; i < 2 && j < 2; ++i, ++j) {}
    +}
    +''');
    + }
    +
    + test_functionVariable_multiple() async {
    + await assertDiagnostics(r'''
    +void f() {
    + String? a, b, c;
    +}
    +''', [
    + lint(24, 1),
    + ]);
    + }
    +
    + test_functionVariable_single() async {
    + await assertNoDiagnostics(r'''
    +void f() {
    + String? a;
    +}
    +''');
    + }
    +
    + test_topLevel_multiple() async {
    + await assertDiagnostics(r'''
    +String? a, b, c;
    +''', [
    + lint(11, 1),
    + ]);
    + }
    +
    + test_topLevel_single() async {
    + await assertNoDiagnostics(r'''
    +String? a;
    +''');
    + }
    +}
    diff --git a/pkg/linter/test_data/rules/avoid_multiple_declarations_per_line.dart b/pkg/linter/test_data/rules/avoid_multiple_declarations_per_line.dart
    deleted file mode 100644
    index 3c23858..0000000
    --- a/pkg/linter/test_data/rules/avoid_multiple_declarations_per_line.dart
    +++ /dev/null
    @@ -1,59 +0,0 @@
    -// Copyright (c) 2021, 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.
    -
    -// ignore_for_file: unused_local_variable
    -
    -String? badFoo, badBar, badBaz; // LINT
    -
    -String? goodFoo;
    -String? goodBar;
    -String? goodBaz;
    -
    -methodContainingBadDeclaration() {
    - String? badFoo, badBar, badBaz; // LINT
    -}
    -
    -methodContainingGoodDeclaration() {
    - String? goodFoo;
    - String? goodBar;
    - String? goodBaz;
    -}
    -
    -class BadClass {
    - String? foo, bar, baz; // LINT
    -
    - methodContainingBadDeclaration() {
    - String? badFoo, badBar, badBaz; // LINT
    - }
    -}
    -
    -class GoodClass {
    - String? foo;
    - String? bar;
    - String? baz;
    -
    - methodContainingGoodDeclaration() {
    - String? goodFoo;
    - String? goodBar;
    - String? goodBaz;
    - }
    -}
    -
    -extension BadExtension on Object {
    - static String? badFoo, badBar, badBaz; // LINT
    -}
    -
    -extension GoodExtension on Object {
    - static String? foo;
    - static String? bar;
    - static String? baz;
    -}
    -
    -// https://github.com/dart-lang/linter/issues/2543
    -okInForLoop() {
    - for (var i = 0, j = 0; i < 2 && j < 2; ++i, ++j) // OK
    - {
    - //
    - }
    -}

    To view, visit change 329140. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: newchange
    Gerrit-Project: sdk
    Gerrit-Branch: main
    Gerrit-Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
    Gerrit-Change-Number: 329140
    Gerrit-PatchSet: 1
    Gerrit-Owner: Samuel Rawlins <sraw...@google.com>
    Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
    Gerrit-Attention: Phil Quitslund <pquit...@google.com>

    Samuel Rawlins (Gerrit)

    unread,
    Oct 4, 2023, 11:03:29 PM10/4/23
    to rev...@dartlang.org, Phil Quitslund, CBuild, Commit Queue

    Attention is currently required from: Phil Quitslund.

    Patch set 1:Auto-Submit +1

    View Change

      To view, visit change 329140. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-MessageType: comment
      Gerrit-Project: sdk
      Gerrit-Branch: main
      Gerrit-Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
      Gerrit-Change-Number: 329140
      Gerrit-PatchSet: 1
      Gerrit-Owner: Samuel Rawlins <sraw...@google.com>
      Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
      Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
      Gerrit-Attention: Phil Quitslund <pquit...@google.com>
      Gerrit-Comment-Date: Thu, 05 Oct 2023 03:03:25 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes

      Phil Quitslund (Gerrit)

      unread,
      Oct 6, 2023, 6:50:54 PM10/6/23
      to Samuel Rawlins, rev...@dartlang.org, CBuild, Commit Queue

      Attention is currently required from: Samuel Rawlins.

      Patch set 1:Code-Review +1Commit-Queue +2

      View Change

        To view, visit change 329140. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-MessageType: comment
        Gerrit-Project: sdk
        Gerrit-Branch: main
        Gerrit-Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
        Gerrit-Change-Number: 329140
        Gerrit-PatchSet: 1
        Gerrit-Owner: Samuel Rawlins <sraw...@google.com>
        Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
        Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
        Gerrit-Comment-Date: Fri, 06 Oct 2023 22:50:51 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes

        Commit Queue (Gerrit)

        unread,
        Oct 6, 2023, 7:23:56 PM10/6/23
        to Samuel Rawlins, rev...@dartlang.org, Phil Quitslund, CBuild

        Commit Queue submitted this change.

        View Change

        Approvals: Samuel Rawlins: Send CL to CQ automatically after approval Phil Quitslund: Looks good to me, approved; Commit
        linter: Move avoid_multiple_declarations_per_line tests

        Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
        Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329140
        Auto-Submit: Samuel Rawlins <sraw...@google.com>
        Reviewed-by: Phil Quitslund <pquit...@google.com>
        Commit-Queue: Phil Quitslund <pquit...@google.com>

        ---
        M pkg/linter/test/rules/all.dart
        A pkg/linter/test/rules/avoid_multiple_declarations_per_line_test.dart
        D pkg/linter/test_data/rules/avoid_multiple_declarations_per_line.dart
        3 files changed, 99 insertions(+), 59 deletions(-)

        
        
        diff --git a/pkg/linter/test/rules/all.dart b/pkg/linter/test/rules/all.dart
        index 4ec5355..65d4c69 100644

        --- a/pkg/linter/test/rules/all.dart
        +++ b/pkg/linter/test/rules/all.dart
        @@ -16,6 +16,8 @@
        import 'avoid_function_literals_in_foreach_calls_test.dart'
        as avoid_function_literals_in_foreach_calls;
        import 'avoid_init_to_null_test.dart' as avoid_init_to_null;
        +import 'avoid_multiple_declarations_per_line_test.dart'
        + as avoid_multiple_declarations_per_line;
        import 'avoid_positional_boolean_parameters_test.dart'
        as avoid_positional_boolean_parameters;
        import 'avoid_print_test.dart' as avoid_print;
        @@ -260,6 +262,7 @@

        To view, visit change 329140. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-MessageType: merged
        Gerrit-Project: sdk
        Gerrit-Branch: main
        Gerrit-Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
        Gerrit-Change-Number: 329140
        Gerrit-PatchSet: 2
        Gerrit-Owner: Samuel Rawlins <sraw...@google.com>

        CBuild (Gerrit)

        unread,
        Oct 6, 2023, 7:46:22 PM10/6/23
        to Commit Queue, Samuel Rawlins, rev...@dartlang.org, Phil Quitslund

          To view, visit change 329140. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-MessageType: comment
          Gerrit-Project: sdk
          Gerrit-Branch: main
          Gerrit-Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
          Gerrit-Change-Number: 329140
          Gerrit-PatchSet: 2
          Gerrit-Owner: Samuel Rawlins <sraw...@google.com>
          Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
          Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
          Gerrit-Comment-Date: Fri, 06 Oct 2023 23:46:18 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: No
          Reply all
          Reply to author
          Forward
          0 new messages