From: Steve Hancock Date: Thu, 30 Jul 2020 14:01:37 +0000 (-0700) Subject: fix for git #33, space after '->' X-Git-Tag: 20200822~31 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0413683ff5f772ac5230c52e1e30e47c31324718;p=perltidy.git fix for git #33, space after '->' --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 3776ecb5..08a03995 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2981,6 +2981,14 @@ sub respace_tokens { my $rcopy = copy_token_as_type( $rtoken_vars, '->', '->' ); $store_token->($rcopy); + # store a blank after the arrow if requested + # added for issue git #33 + if ($want_right_space{'->'} == WS_YES ) { + my $rcopy = + copy_token_as_type( $rtoken_vars, 'b', ' ' ); + $store_token->($rcopy); + } + # then reset the current token to be the remainder, # and reset the whitespace flag according to the arrow $token = $rtoken_vars->[_TOKEN_] = $token_save; diff --git a/t/snippets/expect/git33.def b/t/snippets/expect/git33.def new file mode 100644 index 00000000..c1250481 --- /dev/null +++ b/t/snippets/expect/git33.def @@ -0,0 +1,5 @@ +# test -wls='->' -wrs='->' +use Net::Ping; +my ($ping) = Net::Ping->new(); +$ping->ping($host); + diff --git a/t/snippets/expect/git33.git33 b/t/snippets/expect/git33.git33 new file mode 100644 index 00000000..32fa8d33 --- /dev/null +++ b/t/snippets/expect/git33.git33 @@ -0,0 +1,5 @@ +# test -wls='->' -wrs='->' +use Net::Ping; +my ($ping) = Net::Ping -> new(); +$ping -> ping($host); + diff --git a/t/snippets/git33.in b/t/snippets/git33.in new file mode 100644 index 00000000..c1250481 --- /dev/null +++ b/t/snippets/git33.in @@ -0,0 +1,5 @@ +# test -wls='->' -wrs='->' +use Net::Ping; +my ($ping) = Net::Ping->new(); +$ping->ping($host); + diff --git a/t/snippets/git33.par b/t/snippets/git33.par new file mode 100644 index 00000000..d4fa6635 --- /dev/null +++ b/t/snippets/git33.par @@ -0,0 +1,2 @@ +-wls='->' -wrs='->' + diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 3efae380..c353cf90 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -258,6 +258,8 @@ ../snippets21.t sot.sot ../snippets21.t prune.def ../snippets21.t align33.def +../snippets21.t gnu7.def +../snippets21.t gnu7.gnu ../snippets3.t ce_wn1.ce_wn ../snippets3.t ce_wn1.def ../snippets3.t colin.colin @@ -398,5 +400,5 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets21.t gnu7.def -../snippets21.t gnu7.gnu +../snippets21.t git33.def +../snippets21.t git33.git33 diff --git a/t/snippets21.t b/t/snippets21.t index 4b6ce439..112ba32f 100644 --- a/t/snippets21.t +++ b/t/snippets21.t @@ -10,6 +10,8 @@ #7 align33.def #8 gnu7.def #9 gnu7.gnu +#10 git33.def +#11 git33.git33 # To locate test #13 you can search for its name or the string '#13' @@ -27,7 +29,11 @@ BEGIN { # BEGIN SECTION 1: Parameter combinations # ########################################### $rparams = { - 'def' => "", + 'def' => "", + 'git33' => <<'----------', +-wls='->' -wrs='->' + +---------- 'gnu' => "-gnu", 'lop' => "-nlop", 'sot' => "-sot -sct", @@ -49,6 +55,14 @@ $tp = $opt_t ? "t" : "f"; $rm = $numbstyle ? "t" : "f"; $pa = $showurl ? "t" : "f"; $nh = $seq_number ? "t" : "f"; +---------- + + 'git33' => <<'----------', +# test -wls='->' -wrs='->' +use Net::Ping; +my ($ping) = Net::Ping->new(); +$ping->ping($host); + ---------- 'gnu7' => <<'----------', @@ -450,6 +464,30 @@ else } #9........... }, + + 'git33.def' => { + source => "git33", + params => "def", + expect => <<'#10...........', +# test -wls='->' -wrs='->' +use Net::Ping; +my ($ping) = Net::Ping->new(); +$ping->ping($host); + +#10........... + }, + + 'git33.git33' => { + source => "git33", + params => "git33", + expect => <<'#11...........', +# test -wls='->' -wrs='->' +use Net::Ping; +my ($ping) = Net::Ping -> new(); +$ping -> ping($host); + +#11........... + }, }; my $ntests = 0 + keys %{$rtests};