]> git.donarmstrong.com Git - perltidy.git/commitdiff
Added 3 new tests; snippets file format improved
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 12 Nov 2018 20:25:39 +0000 (12:25 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 12 Nov 2018 20:25:39 +0000 (12:25 -0800)
17 files changed:
.gitignore
t/snippets/expect/align10.def [new file with mode: 0644]
t/snippets/expect/align11.def [new file with mode: 0644]
t/snippets/expect/align12.def [new file with mode: 0644]
t/snippets1.t
t/snippets10.t
t/snippets11.t
t/snippets12.t
t/snippets13.t [new file with mode: 0644]
t/snippets2.t
t/snippets3.t
t/snippets4.t
t/snippets5.t
t/snippets6.t
t/snippets7.t
t/snippets8.t
t/snippets9.t

index 5f20ec6b92c97c52b476b3c6bb69ff5bcc4d320a..bba3e7d68991d81f34bc521051ad6ad366569a8a 100644 (file)
@@ -2,6 +2,7 @@
 *.ERR
 *.LOG
 *.bak
+*.ba1
 *.log
 *.sw?
 *.tar.gz
diff --git a/t/snippets/expect/align10.def b/t/snippets/expect/align10.def
new file mode 100644 (file)
index 0000000..fe0b86c
--- /dev/null
@@ -0,0 +1,2 @@
+$message     =~ &rhs_wordwrap( $message, $width );
+$message_len =~ split( /^/, $message );
diff --git a/t/snippets/expect/align11.def b/t/snippets/expect/align11.def
new file mode 100644 (file)
index 0000000..f429511
--- /dev/null
@@ -0,0 +1,4 @@
+my $accountno = getnextacctno( $env, $bornum, $dbh );
+my $item      = getiteminformation( $env, $itemno );
+my $account   = "Insert into accountlines
+ bla bla";
diff --git a/t/snippets/expect/align12.def b/t/snippets/expect/align12.def
new file mode 100644 (file)
index 0000000..25edf2e
--- /dev/null
@@ -0,0 +1,3 @@
+    my $type = shift || "o";
+    my $fname  = ( $type eq 'oo'               ? 'orte_city' : 'orte' );
+    my $suffix = ( $coord_system eq 'standard' ? ''          : '-orig' );
index e7c91e2eb15538852e6e6bbf799e2f561880577b..bd8a5aa05557f832dcbc7efb18addb41d01850c3 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 105484.def
+#2 align1.def
+#3 align2.def
+#4 align3.def
+#5 align4.def
+#6 align5.def
+#7 align6.def
+#8 align7.def
+#9 align8.def
+#10 align9.def
+#11 andor1.def
+#12 andor10.def
+#13 andor2.def
+#14 andor3.def
+#15 andor4.def
+#16 andor5.def
+#17 andor6.def
+#18 andor7.def
+#19 andor8.def
+#20 andor9.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index e89f19cdcba1674d5e5a9e2845a1ce6607f7b184..f7d153a356278ebc0c5d6808cf0f2191382d5ed2 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:12 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 scl.def
+#2 scl.scl
+#3 semicolon2.def
+#4 side_comments1.def
+#5 sil1.def
+#6 sil1.sil
+#7 slashslash.def
+#8 smart.def
+#9 space1.def
+#10 space2.def
+#11 space3.def
+#12 space4.def
+#13 space5.def
+#14 structure1.def
+#15 style.def
+#16 style.style1
+#17 style.style2
+#18 style.style3
+#19 style.style4
+#20 style.style5
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index 0ddbe0344c933e4640efb0c304dea7f208b27cff..1f174ce17da713b029f34dfa558ffb8eccb606e2 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:12 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 sub1.def
+#2 sub2.def
+#3 switch1.def
+#4 syntax1.def
+#5 syntax2.def
+#6 ternary1.def
+#7 ternary2.def
+#8 tick1.def
+#9 trim_quote.def
+#10 tso1.def
+#11 tso1.tso
+#12 tutor.def
+#13 undoci1.def
+#14 use1.def
+#15 use2.def
+#16 version1.def
+#17 version2.def
+#18 vert.def
+#19 vmll.def
+#20 vmll.vmll
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index 5fd19bfff02376f057ca869de90380ccb867f8ee..c0e3672405fa0f41aa60ca4bcf658865503470db 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:12 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 vtc1.def
+#2 vtc1.vtc
+#3 vtc2.def
+#4 vtc2.vtc
+#5 vtc3.def
+#6 vtc3.vtc
+#7 vtc4.def
+#8 vtc4.vtc
+#9 wn1.def
+#10 wn1.wn
+#11 wn2.def
+#12 wn2.wn
+#13 wn3.def
+#14 wn3.wn
+#15 wn4.def
+#16 wn4.wn
+#17 wn5.def
+#18 wn5.wn
+#19 wn6.def
+#20 wn6.wn
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
diff --git a/t/snippets13.t b/t/snippets13.t
new file mode 100644 (file)
index 0000000..6998168
--- /dev/null
@@ -0,0 +1,136 @@
+# Created with: ./make_t.pl
+
+# Contents:
+#1 align10.def
+#2 align11.def
+#3 align12.def
+
+# To locate test #13 you can search for its name or the string '#13'
+
+use strict;
+use Test;
+use Carp;
+use Perl::Tidy;
+my $rparams;
+my $rsources;
+my $rtests;
+
+BEGIN {
+
+    ###########################################
+    # BEGIN SECTION 1: Parameter combinations #
+    ###########################################
+    $rparams = { 'def' => "", };
+
+    ############################
+    # BEGIN SECTION 2: Sources #
+    ############################
+    $rsources = {
+
+        'align10' => <<'----------',
+$message =~ &rhs_wordwrap( $message, $width );
+$message_len =~ split( /^/, $message );
+----------
+
+        'align11' => <<'----------',
+my $accountno = getnextacctno( $env, $bornum, $dbh );
+my $item = getiteminformation( $env, $itemno );
+my $account = "Insert into accountlines
+ bla bla";
+----------
+
+        'align12' => <<'----------',
+    my $type = shift || "o";
+    my $fname  = ( $type eq 'oo'               ? 'orte_city' : 'orte' );
+    my $suffix = ( $coord_system eq 'standard' ? ''          : '-orig' );
+----------
+    };
+
+    ####################################
+    # BEGIN SECTION 3: Expected output #
+    ####################################
+    $rtests = {
+
+        'align10.def' => {
+            source => "align10",
+            params => "def",
+            expect => <<'#1...........',
+$message     =~ &rhs_wordwrap( $message, $width );
+$message_len =~ split( /^/, $message );
+#1...........
+        },
+
+        'align11.def' => {
+            source => "align11",
+            params => "def",
+            expect => <<'#2...........',
+my $accountno = getnextacctno( $env, $bornum, $dbh );
+my $item      = getiteminformation( $env, $itemno );
+my $account   = "Insert into accountlines
+ bla bla";
+#2...........
+        },
+
+        'align12.def' => {
+            source => "align12",
+            params => "def",
+            expect => <<'#3...........',
+    my $type = shift || "o";
+    my $fname  = ( $type eq 'oo'               ? 'orte_city' : 'orte' );
+    my $suffix = ( $coord_system eq 'standard' ? ''          : '-orig' );
+#3...........
+        },
+    };
+
+    my $ntests = 0 + keys %{$rtests};
+    plan tests => $ntests;
+}
+
+###############
+# EXECUTE TESTS
+###############
+
+foreach my $key ( sort keys %{$rtests} ) {
+    my $output;
+    my $sname  = $rtests->{$key}->{source};
+    my $expect = $rtests->{$key}->{expect};
+    my $pname  = $rtests->{$key}->{params};
+    my $source = $rsources->{$sname};
+    my $params = defined($pname) ? $rparams->{$pname} : "";
+    my $stderr_string;
+    my $errorfile_string;
+    my $err = Perl::Tidy::perltidy(
+        source      => \$source,
+        destination => \$output,
+        perltidyrc  => \$params,
+        argv        => '',             # for safety; hide any ARGV from perltidy
+        stderr      => \$stderr_string,
+        errorfile => \$errorfile_string,    # not used when -se flag is set
+    );
+    if ( $err || $stderr_string || $errorfile_string ) {
+        if ($err) {
+            print STDERR
+"This error received calling Perl::Tidy with '$sname' + '$pname'\n";
+            ok( !$err );
+        }
+        if ($stderr_string) {
+            print STDERR "---------------------\n";
+            print STDERR "<<STDERR>>\n$stderr_string\n";
+            print STDERR "---------------------\n";
+            print STDERR
+"This error received calling Perl::Tidy with '$sname' + '$pname'\n";
+            ok( !$stderr_string );
+        }
+        if ($errorfile_string) {
+            print STDERR "---------------------\n";
+            print STDERR "<<.ERR file>>\n$errorfile_string\n";
+            print STDERR "---------------------\n";
+            print STDERR
+"This error received calling Perl::Tidy with '$sname' + '$pname'\n";
+            ok( !$errorfile_string );
+        }
+    }
+    else {
+        ok( $output, $expect );
+    }
+}
index 997f2a9d864c029316c1c68e65698dd6d946fb2d..03a62595fc7657a726ff0b49b02075d3a371da94 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 angle.def
+#2 arrows1.def
+#3 arrows2.def
+#4 attrib1.def
+#5 attrib2.def
+#6 attrib3.def
+#7 bar1.bar
+#8 bar1.def
+#9 block1.def
+#10 boc1.boc
+#11 boc1.def
+#12 boc2.boc
+#13 boc2.def
+#14 break1.def
+#15 break2.def
+#16 break3.def
+#17 break4.def
+#18 carat.def
+#19 ce1.ce
+#20 ce1.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index 4e97c6b56d5fe67f9dd88efc69730962c3c53061..aa37aef90991a12ec374f68fbbd6f3bf42169ee0 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 ce_wn1.ce_wn
+#2 ce_wn1.def
+#3 colin.colin
+#4 colin.def
+#5 essential.def
+#6 essential.essential1
+#7 essential.essential2
+#8 extrude1.def
+#9 extrude1.extrude
+#10 extrude2.def
+#11 extrude2.extrude
+#12 extrude3.def
+#13 extrude3.extrude
+#14 extrude4.def
+#15 extrude4.extrude
+#16 fabrice_bug.def
+#17 fabrice_bug.fabrice_bug
+#18 format1.def
+#19 given1.def
+#20 gnu1.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index 8ea7115251f01b09d376588ea25d92fd427df8e1..0c5905a5fd66e574a1cc68000cb31b0bc67d5365 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 gnu1.gnu
+#2 gnu2.def
+#3 gnu2.gnu
+#4 gnu3.def
+#5 gnu3.gnu
+#6 gnu4.def
+#7 gnu4.gnu
+#8 hanging_side_comments1.def
+#9 hanging_side_comments2.def
+#10 hash1.def
+#11 hashbang.def
+#12 here1.def
+#13 html1.def
+#14 html1.html
+#15 ident1.def
+#16 if1.def
+#17 iscl1.def
+#18 iscl1.iscl
+#19 label1.def
+#20 lextest1.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index 354194d9b65fa8434a60da4e40152ab85dbacab4..3279c82543cda560a637467cb143ebd778b09ddf 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 list1.def
+#2 listop1.def
+#3 listop2.def
+#4 lp1.def
+#5 lp1.lp
+#6 mangle1.def
+#7 mangle1.mangle
+#8 mangle2.def
+#9 mangle2.mangle
+#10 mangle3.def
+#11 mangle3.mangle
+#12 math1.def
+#13 math2.def
+#14 math3.def
+#15 math4.def
+#16 nasc.def
+#17 nasc.nasc
+#18 nothing.def
+#19 nothing.nothing
+#20 otr1.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index c581d4c92c445dde79926d9c2f62fd2d19713a99..0e1e00f1c1d5efbce7f4273c9aecf71aa7447062 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 otr1.otr
+#2 pbp1.def
+#3 pbp1.pbp
+#4 pbp2.def
+#5 pbp2.pbp
+#6 pbp3.def
+#7 pbp3.pbp
+#8 pbp4.def
+#9 pbp4.pbp
+#10 pbp5.def
+#11 pbp5.pbp
+#12 print1.def
+#13 q1.def
+#14 q2.def
+#15 recombine1.def
+#16 recombine2.def
+#17 recombine3.def
+#18 recombine4.def
+#19 rt101547.def
+#20 rt102371.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index 520105953498b5bd037fec3df8f34c3462ffc7aa..078fcb68ea1fdc2ec8f3e0fd51578e7809936b7c 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 rt102451.def
+#2 rt104427.def
+#3 rt106492.def
+#4 rt107832.def
+#5 rt107832.rt107832
+#6 rt111519.def
+#7 rt111519.rt111519
+#8 rt112534.def
+#9 rt113689.def
+#10 rt113689.rt113689
+#11 rt113792.def
+#12 rt114359.def
+#13 rt114909.def
+#14 rt116344.def
+#15 rt119140.def
+#16 rt119588.def
+#17 rt119970.def
+#18 rt119970.rt119970
+#19 rt123492.def
+#20 rt123749.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index d6ceae08e005646edff195f868cc57c1ee8b0e18..77c50a2fcd876b74829585a0832df9b15fb3acb7 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 rt123749.rt123749
+#2 rt123774.def
+#3 rt124114.def
+#4 rt124354.def
+#5 rt124354.rt124354
+#6 rt125012.def
+#7 rt125012.rt125012
+#8 rt125506.def
+#9 rt125506.rt125506
+#10 rt126965.def
+#11 rt15735.def
+#12 rt18318.def
+#13 rt18318.rt18318
+#14 rt27000.def
+#15 rt31741.def
+#16 rt49289.def
+#17 rt50702.def
+#18 rt50702.rt50702
+#19 rt68870.def
+#20 rt70747.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;
index 14f2d029715ba7a9eb56ccf8a257e942deed1570..734ca6240631e4af583edc9ebaf764f462337184 100644 (file)
@@ -1,8 +1,28 @@
-# **This script was automatically generated**
 # Created with: ./make_t.pl
-# Sun Nov 11 06:54:11 2018
 
-# To locate test #13 for example, search for the string '#13'
+# Contents:
+#1 rt70747.rt70747
+#2 rt74856.def
+#3 rt78156.def
+#4 rt78764.def
+#5 rt79813.def
+#6 rt79947.def
+#7 rt80645.def
+#8 rt81852.def
+#9 rt81852.rt81852
+#10 rt81854.def
+#11 rt87502.def
+#12 rt93197.def
+#13 rt94338.def
+#14 rt95419.def
+#15 rt95708.def
+#16 rt96021.def
+#17 rt96101.def
+#18 rt98902.def
+#19 rt98902.rt98902
+#20 rt99961.def
+
+# To locate test #13 you can search for its name or the string '#13'
 
 use strict;
 use Test;