]> git.donarmstrong.com Git - perltidy.git/commitdiff
add test case c158
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 30 Aug 2022 13:53:10 +0000 (06:53 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 30 Aug 2022 13:53:10 +0000 (06:53 -0700)
lib/Perl/Tidy/Tokenizer.pm
t/snippets/c158.in [new file with mode: 0644]
t/snippets/expect/c158.def [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets26.t

index c9be062794ccb82e93895d3ee4bc64b60280d93f..821ca601629306c2c840360d63763a1d6575f0ea 100644 (file)
@@ -5146,22 +5146,25 @@ EOM
                     $continuation_string_in_tokenizer .=
                       ( $in_statement_continuation > 0 ) ? '1' : '0';
 
-   #  Sometimes we want to give an opening brace continuation indentation,
-   #  and sometimes not.  For code blocks, we don't do it, so that the leading
-   #  '{' gets outdented, like this:
-   #
-   #   if ( !$output_block_type[$i]
-   #     && ($in_statement_continuation) )
-   #   {           <--outdented
-   #
-   #  For other types, we will give them continuation indentation.  For example,
-   #  here is how a list looks with the opening paren indented:
-   #
-   #     @LoL =
-   #       ( [ "fred", "barney" ], [ "george", "jane", "elroy" ],
-   #         [ "homer", "marge", "bart" ], );
-   #
-   #  This looks best when 'ci' is one-half of the indentation  (i.e., 2 and 4)
+                    #  Sometimes we want to give an opening brace
+                    #  continuation indentation, and sometimes not.  For code
+                    #  blocks, we don't do it, so that the leading '{' gets
+                    #  outdented, like this:
+                    #
+                    #   if ( !$output_block_type[$i]
+                    #     && ($in_statement_continuation) )
+                    #   {           <--outdented
+                    #
+                    #  For other types, we will give them continuation
+                    #  indentation.  For example, here is how a list looks
+                    #  with the opening paren indented:
+                    #
+                    #  @LoL =
+                    #    ( [ "fred", "barney" ], [ "george", "jane", "elroy" ],
+                    #      [ "homer", "marge", "bart" ], );
+                    #
+                    #  This looks best when 'ci' is one-half of the
+                    #  indentation  (i.e., 2 and 4)
 
                     my $total_ci = $ci_string_sum;
                     if (
@@ -5298,7 +5301,10 @@ EOM
                         }
                     }
 
-                    # be sure binary operators get continuation indentation
+                    # Be sure binary operators get continuation indentation.
+                    # Note: the check on $nesting_block_flag is only needed
+                    # to add ci to binary operators following a 'try' block,
+                    # or similar extended syntax block operator (see c158).
                     if (
                         ( $nesting_block_flag || $nesting_list_flag )
                         && (   $type_i eq 'k' && $is_binary_keyword{$tok_i}
diff --git a/t/snippets/c158.in b/t/snippets/c158.in
new file mode 100644 (file)
index 0000000..fda9aec
--- /dev/null
@@ -0,0 +1,5 @@
+my $meta = try { $package->meta }
+or die "$package does not have a ->meta method\n";
+
+my ($curr) = current();
+err(@_);
diff --git a/t/snippets/expect/c158.def b/t/snippets/expect/c158.def
new file mode 100644 (file)
index 0000000..2ab3edb
--- /dev/null
@@ -0,0 +1,5 @@
+my $meta = try { $package->meta }
+  or die "$package does not have a ->meta method\n";
+
+my ($curr) = current();
+err(@_);
index ec4c13d16e21fbdb81713388ae32c9524c3676a5..d8e9f78f4bed0630117a9b69709ff7e072e7fb3a 100644 (file)
 ../snippets26.t        git106.def
 ../snippets26.t        git106.git106
 ../snippets26.t        c154.def
+../snippets26.t        code_skipping.code_skipping
 ../snippets3.t ce_wn1.ce_wn
 ../snippets3.t ce_wn1.def
 ../snippets3.t colin.colin
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets26.t        code_skipping.code_skipping
+../snippets26.t        c158.def
index c553ac72122c33b2654718165154ea2cabec5270..3e466a6d817a398960f56cdc5e118e268abb2fc9 100644 (file)
@@ -16,6 +16,7 @@
 #13 git106.git106
 #14 c154.def
 #15 code_skipping.code_skipping
+#16 c158.def
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -151,6 +152,14 @@ for (
     ...;
 }
 }}}}
+----------
+
+        'c158' => <<'----------',
+my $meta = try { $package->meta }
+or die "$package does not have a ->meta method\n";
+
+my ($curr) = current();
+err(@_);
 ----------
 
         'code_skipping' => <<'----------',
@@ -750,6 +759,18 @@ my $self    = shift;
 my $cloning = shift;
 #15...........
         },
+
+        'c158.def' => {
+            source => "c158",
+            params => "def",
+            expect => <<'#16...........',
+my $meta = try { $package->meta }
+  or die "$package does not have a ->meta method\n";
+
+my ($curr) = current();
+err(@_);
+#16...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};