]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix for git #33, space after '->'
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 30 Jul 2020 14:01:37 +0000 (07:01 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 30 Jul 2020 14:01:37 +0000 (07:01 -0700)
lib/Perl/Tidy/Formatter.pm
t/snippets/expect/git33.def [new file with mode: 0644]
t/snippets/expect/git33.git33 [new file with mode: 0644]
t/snippets/git33.in [new file with mode: 0644]
t/snippets/git33.par [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets21.t

index 3776ecb58dd21c2c8aebe5a2fee6338e9e3143b2..08a039959ff24486037cacf19fb0e9270645bfbc 100644 (file)
@@ -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 (file)
index 0000000..c125048
--- /dev/null
@@ -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 (file)
index 0000000..32fa8d3
--- /dev/null
@@ -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 (file)
index 0000000..c125048
--- /dev/null
@@ -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 (file)
index 0000000..d4fa663
--- /dev/null
@@ -0,0 +1,2 @@
+-wls='->' -wrs='->'
+
index 3efae38099ecdc22fa63b2d5428ac9d8be518c59..c353cf90096fc781a49b788a8fb8dc339ddd1052 100644 (file)
 ../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
 ../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
index 4b6ce4392dee4c5b0f8d5d471c33fdc4563e6694..112ba32fc686f0b1967a5faa33e374d841ff323a 100644 (file)
@@ -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};