From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Wed, 18 Nov 2020 20:28:04 +0000 (-0800)
Subject: add test case for if/elsif/else alignment
X-Git-Tag: 20201202~29
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cf951405809ce1ed7eefa8c32fa2ee19d3ef059c;p=perltidy.git

add test case for if/elsif/else alignment
---

diff --git a/t/snippets/align34.in b/t/snippets/align34.in
new file mode 100644
index 00000000..e6671065
--- /dev/null
+++ b/t/snippets/align34.in
@@ -0,0 +1,10 @@
+# align all '{' and runs of '='
+if    ( $line =~ /^NAME>(.*)/i )       { $Cookies{'name'} = $1; }
+elsif ( $line =~ /^EMAIL>(.*)/i )      { $email = $1; }
+elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) { $ipaddress = $1; }
+elsif ( $line =~ /^<!--(.*)-->/i )     { $remoteuser = $1; }
+elsif ( $line =~ /^PASSWORD>(.*)/i )   { next; }
+elsif ( $line =~ /^IMAGE>(.*)/i )      { $image_url = $1; }
+elsif ( $line =~ /^LINKNAME>(.*)/i )   { $linkname = $1; }
+elsif ( $line =~ /^LINKURL>(.*)/i )    { $linkurl = $1; }
+else                                   { $body .= $line; }
diff --git a/t/snippets/expect/align34.def b/t/snippets/expect/align34.def
new file mode 100644
index 00000000..0c6d8000
--- /dev/null
+++ b/t/snippets/expect/align34.def
@@ -0,0 +1,10 @@
+# align all '{' and runs of '='
+if    ( $line =~ /^NAME>(.*)/i )       { $Cookies{'name'} = $1; }
+elsif ( $line =~ /^EMAIL>(.*)/i )      { $email           = $1; }
+elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) { $ipaddress       = $1; }
+elsif ( $line =~ /^<!--(.*)-->/i )     { $remoteuser      = $1; }
+elsif ( $line =~ /^PASSWORD>(.*)/i )   { next; }
+elsif ( $line =~ /^IMAGE>(.*)/i )      { $image_url = $1; }
+elsif ( $line =~ /^LINKNAME>(.*)/i )   { $linkname  = $1; }
+elsif ( $line =~ /^LINKURL>(.*)/i )    { $linkurl   = $1; }
+else                                   { $body .= $line; }
diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt
index 6fc3d399..12dc2604 100644
--- a/t/snippets/packing_list.txt
+++ b/t/snippets/packing_list.txt
@@ -444,3 +444,4 @@
 ../snippets9.t	rt98902.def
 ../snippets9.t	rt98902.rt98902
 ../snippets9.t	rt99961.def
+../snippets23.t	align34.def
diff --git a/t/snippets23.t b/t/snippets23.t
index bd0a2d4a..3b67a41f 100644
--- a/t/snippets23.t
+++ b/t/snippets23.t
@@ -16,6 +16,7 @@
 #13 wnxl.wnxl2
 #14 wnxl.wnxl3
 #15 wnxl.wnxl4
+#16 align34.def
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -74,6 +75,19 @@ BEGIN {
     ############################
     $rsources = {
 
+        'align34' => <<'----------',
+# align all '{' and runs of '='
+if    ( $line =~ /^NAME>(.*)/i )       { $Cookies{'name'} = $1; }
+elsif ( $line =~ /^EMAIL>(.*)/i )      { $email = $1; }
+elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) { $ipaddress = $1; }
+elsif ( $line =~ /^<!--(.*)-->/i )     { $remoteuser = $1; }
+elsif ( $line =~ /^PASSWORD>(.*)/i )   { next; }
+elsif ( $line =~ /^IMAGE>(.*)/i )      { $image_url = $1; }
+elsif ( $line =~ /^LINKNAME>(.*)/i )   { $linkname = $1; }
+elsif ( $line =~ /^LINKURL>(.*)/i )    { $linkurl = $1; }
+else                                   { $body .= $line; }
+----------
+
         'boa' => <<'----------',
 my @field
   : field
@@ -470,6 +484,23 @@ threads->create( sub {
 } )->join();
 #15...........
         },
+
+        'align34.def' => {
+            source => "align34",
+            params => "def",
+            expect => <<'#16...........',
+# align all '{' and runs of '='
+if    ( $line =~ /^NAME>(.*)/i )       { $Cookies{'name'} = $1; }
+elsif ( $line =~ /^EMAIL>(.*)/i )      { $email           = $1; }
+elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) { $ipaddress       = $1; }
+elsif ( $line =~ /^<!--(.*)-->/i )     { $remoteuser      = $1; }
+elsif ( $line =~ /^PASSWORD>(.*)/i )   { next; }
+elsif ( $line =~ /^IMAGE>(.*)/i )      { $image_url = $1; }
+elsif ( $line =~ /^LINKNAME>(.*)/i )   { $linkname  = $1; }
+elsif ( $line =~ /^LINKURL>(.*)/i )    { $linkurl   = $1; }
+else                                   { $body .= $line; }
+#16...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};