From: Steve Hancock Date: Mon, 12 Nov 2018 20:25:39 +0000 (-0800) Subject: Added 3 new tests; snippets file format improved X-Git-Tag: 20181117~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8e2599f4934a9275309342d15c5f1ccd06e8d2a3;p=perltidy.git Added 3 new tests; snippets file format improved --- diff --git a/.gitignore b/.gitignore index 5f20ec6b..bba3e7d6 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 00000000..fe0b86ce --- /dev/null +++ b/t/snippets/expect/align10.def @@ -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 index 00000000..f429511c --- /dev/null +++ b/t/snippets/expect/align11.def @@ -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 index 00000000..25edf2e3 --- /dev/null +++ b/t/snippets/expect/align12.def @@ -0,0 +1,3 @@ + my $type = shift || "o"; + my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' ); + my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' ); diff --git a/t/snippets1.t b/t/snippets1.t index e7c91e2e..bd8a5aa0 100644 --- a/t/snippets1.t +++ b/t/snippets1.t @@ -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; diff --git a/t/snippets10.t b/t/snippets10.t index e89f19cd..f7d153a3 100644 --- a/t/snippets10.t +++ b/t/snippets10.t @@ -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; diff --git a/t/snippets11.t b/t/snippets11.t index 0ddbe034..1f174ce1 100644 --- a/t/snippets11.t +++ b/t/snippets11.t @@ -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; diff --git a/t/snippets12.t b/t/snippets12.t index 5fd19bff..c0e36724 100644 --- a/t/snippets12.t +++ b/t/snippets12.t @@ -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 index 00000000..69981681 --- /dev/null +++ b/t/snippets13.t @@ -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 "<>\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 ); + } +} diff --git a/t/snippets2.t b/t/snippets2.t index 997f2a9d..03a62595 100644 --- a/t/snippets2.t +++ b/t/snippets2.t @@ -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; diff --git a/t/snippets3.t b/t/snippets3.t index 4e97c6b5..aa37aef9 100644 --- a/t/snippets3.t +++ b/t/snippets3.t @@ -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; diff --git a/t/snippets4.t b/t/snippets4.t index 8ea71152..0c5905a5 100644 --- a/t/snippets4.t +++ b/t/snippets4.t @@ -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; diff --git a/t/snippets5.t b/t/snippets5.t index 354194d9..3279c825 100644 --- a/t/snippets5.t +++ b/t/snippets5.t @@ -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; diff --git a/t/snippets6.t b/t/snippets6.t index c581d4c9..0e1e00f1 100644 --- a/t/snippets6.t +++ b/t/snippets6.t @@ -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; diff --git a/t/snippets7.t b/t/snippets7.t index 52010595..078fcb68 100644 --- a/t/snippets7.t +++ b/t/snippets7.t @@ -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; diff --git a/t/snippets8.t b/t/snippets8.t index d6ceae08..77c50a2f 100644 --- a/t/snippets8.t +++ b/t/snippets8.t @@ -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; diff --git a/t/snippets9.t b/t/snippets9.t index 14f2d029..734ca624 100644 --- a/t/snippets9.t +++ b/t/snippets9.t @@ -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;