From: Steve Hancock Date: Sun, 24 May 2020 20:47:16 +0000 (-0700) Subject: fixed bug with -okwl option and added test case X-Git-Tag: 20200619~24 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=37158352cf8162b7be3608d3900192b81859f758;p=perltidy.git fixed bug with -okwl option and added test case --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 5acd53a3..00f3b872 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -5768,7 +5768,7 @@ EOM # implement outdenting preferences for keywords %outdent_keyword = (); - my @okw = split_words( $rOpts->{'outdent-keyword-okl'} ); + my @okw = split_words( $rOpts->{'outdent-keyword-list'} ); unless (@okw) { @okw = qw(next last redo goto return); # defaults } diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 5fdb5e50..df7f7a6b 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -2824,7 +2824,6 @@ sub delete_unmatched_tokens { BEGIN { my @q; - # These tokens with = may be deleted for vertical aligmnemt @q = ( ',', '=>', '#' ); @is_comma_or_comment{@q} = (1) x scalar(@q); diff --git a/t/snippets/expect/outdent.def b/t/snippets/expect/outdent.def index 3437dfae..ef0c38e2 100644 --- a/t/snippets/expect/outdent.def +++ b/t/snippets/expect/outdent.def @@ -1,4 +1,3 @@ - # test -nola -okw my $i; LOOP: while ( $i = ) { chomp($i); diff --git a/t/snippets/expect/outdent.outdent1 b/t/snippets/expect/outdent.outdent1 index 0952f6e5..b40c8297 100644 --- a/t/snippets/expect/outdent.outdent1 +++ b/t/snippets/expect/outdent.outdent1 @@ -1,4 +1,3 @@ - # test -nola -okw my $i; LOOP: while ( $i = ) { chomp($i); diff --git a/t/snippets/expect/outdent.outdent2 b/t/snippets/expect/outdent.outdent2 new file mode 100644 index 00000000..2672ca81 --- /dev/null +++ b/t/snippets/expect/outdent.outdent2 @@ -0,0 +1,7 @@ + my $i; + LOOP: while ( $i = ) { + chomp($i); + next unless $i; + fixit($i); + } + diff --git a/t/snippets/outdent.in b/t/snippets/outdent.in index b76a6f9d..ef0c38e2 100644 --- a/t/snippets/outdent.in +++ b/t/snippets/outdent.in @@ -1,4 +1,3 @@ -# test -nola -okw my $i; LOOP: while ( $i = ) { chomp($i); diff --git a/t/snippets/outdent1.par b/t/snippets/outdent1.par index e2ba7631..9a0aac17 100644 --- a/t/snippets/outdent1.par +++ b/t/snippets/outdent1.par @@ -1 +1,2 @@ +# test -nola -okw -nola -okw diff --git a/t/snippets/outdent2.par b/t/snippets/outdent2.par new file mode 100644 index 00000000..a02a855e --- /dev/null +++ b/t/snippets/outdent2.par @@ -0,0 +1,2 @@ +# test -okw and -okwl +-okw -okwl='next' diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 7d644264..f4ce326c 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -384,3 +384,4 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def +../snippets20.t outdent.outdent2 diff --git a/t/snippets19.t b/t/snippets19.t index b40eb2e0..693008ed 100644 --- a/t/snippets19.t +++ b/t/snippets19.t @@ -50,7 +50,10 @@ BEGIN { 'misc_tests' => <<'----------', -sts -ssc -sfs -nsak="my for" -ndsm ---------- - 'outdent1' => "-nola -okw", + 'outdent1' => <<'----------', +# test -nola -okw +-nola -okw +---------- 'sbq0' => "-sbq=0", 'sbq2' => "-sbq=2", 'scbb' => "-scbb", @@ -108,7 +111,6 @@ my ( $a, $b, $c ) = @_; # test -nsak="my for" ---------- 'outdent' => <<'----------', -# test -nola -okw my $i; LOOP: while ( $i = ) { chomp($i); @@ -176,7 +178,6 @@ my( $a, $b, $c ) = @_ ; # test -nsak="my for" source => "outdent", params => "def", expect => <<'#2...........', - # test -nola -okw my $i; LOOP: while ( $i = ) { chomp($i); @@ -191,7 +192,6 @@ my( $a, $b, $c ) = @_ ; # test -nsak="my for" source => "outdent", params => "outdent1", expect => <<'#3...........', - # test -nola -okw my $i; LOOP: while ( $i = ) { chomp($i); diff --git a/t/snippets20.t b/t/snippets20.t index 4d98a770..6e201156 100644 --- a/t/snippets20.t +++ b/t/snippets20.t @@ -13,6 +13,7 @@ #10 gnu6.gnu #11 git25.def #12 git25.git25 +#13 outdent.outdent2 # To locate test #13 you can search for its name or the string '#13' @@ -30,10 +31,14 @@ BEGIN { # BEGIN SECTION 1: Parameter combinations # ########################################### $rparams = { - 'ce' => "-cuddled-blocks", - 'def' => "", - 'git25' => "-l=0", - 'gnu' => "-gnu", + 'ce' => "-cuddled-blocks", + 'def' => "", + 'git25' => "-l=0", + 'gnu' => "-gnu", + 'outdent2' => <<'----------', +# test -okw and -okwl +-okw -okwl='next' +---------- 'space6' => <<'----------', -nwrs="+ - / *" -nwls="+ - / *" @@ -101,6 +106,16 @@ my $mapping = [ 'foo10' => undef, }; +---------- + + 'outdent' => <<'----------', + my $i; + LOOP: while ( $i = ) { + chomp($i); + next unless $i; + fixit($i); + } + ---------- 'space6' => <<'----------', @@ -432,6 +447,20 @@ my $mapping = [ #12........... }, + + 'outdent.outdent2' => { + source => "outdent", + params => "outdent2", + expect => <<'#13...........', + my $i; + LOOP: while ( $i = ) { + chomp($i); + next unless $i; + fixit($i); + } + +#13........... + }, }; my $ntests = 0 + keys %{$rtests};