From: Steve Hancock Date: Tue, 13 Nov 2018 22:42:49 +0000 (-0800) Subject: added alignment test snippets X-Git-Tag: 20181117~13 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=822da8f3cccd66234dfa37bc8b38b365e65d5914;p=perltidy.git added alignment test snippets --- diff --git a/t/snippets/README.md b/t/snippets/README.md index 65878325..b6b75710 100644 --- a/t/snippets/README.md +++ b/t/snippets/README.md @@ -2,7 +2,9 @@ This directory contains some snippets of code to do simple checks of perltidy. These are used to create the test files 'snippets\*.t' in the source distribution. -These test files each contain up to about twenty test cases each. +These test files each contain the input file, parameter set, and expected output for +up to about twenty test cases. They are created and maintained by scripts +in this directory. The tests are intended to give a good overall check that perltidy is working correctly at installation but they are by no means exhaustive. Thorough testing @@ -117,6 +119,23 @@ make make test ``` +## A typical example + +Suppose we fix a bug reported as RT #834567, and this bug only occurs when +the parameter -xyzzy is used. Then we do the following: + +- Add a file rt834587.in with the smallest possible test script +- Add a file rt834587.par with one line '-xyzzy'. You can skip this +step if there are no special parameters. +- Enter 'make' and follow the directions +- Enter .RUNME.sh if everything looks good +- Look at the packing list file and verify that the new script is at the end. You +should see names for two cases, 'rt834587.def' and 'rt834587.rt834587', the first +corresponding to running with default parameters and the second with '-xyzzy' parameter. +- You can cd up one directory and run perl on that snippet file as a quick check +- Go up to the git root directory and run 'make test' to verify that all +snippets are still working correctly + ## How to clean up a .par file The '.par' parameter files are just .perltidyrc files, and they can be quite @@ -125,10 +144,10 @@ default parameters, and to write the parameters with the short abbreviations. The following command will do this. ``` - ../../examples/perltidyrc_dump.pl -s -q -d oldfile.par >newfile.par + ../../examples/perltidyrc_dump.pl -s -q -d verbose.par >compact.par ``` -If the output file 'newfile.par' looks ok then it can replace 'messy.par'. You +If the output file 'compact.par' looks ok then it can replace 'verbose.par'. You could then add a single short comment to the new file if it would be helpful. ## Coverage diff --git a/t/snippets/align14.in b/t/snippets/align14.in new file mode 100644 index 00000000..198968ac --- /dev/null +++ b/t/snippets/align14.in @@ -0,0 +1,4 @@ +# align the = +my ($apple) = new Fruit( "Apple1", .1, .30 ); +my ($grapefruit) = new Grapefruit( "Grapefruit1", .3 ); +my ($redgrapefruit) = new RedGrapefruit( "Grapefruit2", .3 ); diff --git a/t/snippets/align15.in b/t/snippets/align15.in new file mode 100644 index 00000000..05c17bb9 --- /dev/null +++ b/t/snippets/align15.in @@ -0,0 +1,6 @@ +# align both = and // +my$color=$opts{'-color'}//'black'; +my$background=$opts{'-background'}//'none'; +my$linewidth=$opts{'-linewidth'}//1; +my$radius=$opts{'-radius'}//0; + diff --git a/t/snippets/expect/align14.def b/t/snippets/expect/align14.def new file mode 100644 index 00000000..198968ac --- /dev/null +++ b/t/snippets/expect/align14.def @@ -0,0 +1,4 @@ +# align the = +my ($apple) = new Fruit( "Apple1", .1, .30 ); +my ($grapefruit) = new Grapefruit( "Grapefruit1", .3 ); +my ($redgrapefruit) = new RedGrapefruit( "Grapefruit2", .3 ); diff --git a/t/snippets/expect/align15.def b/t/snippets/expect/align15.def new file mode 100644 index 00000000..16089f41 --- /dev/null +++ b/t/snippets/expect/align15.def @@ -0,0 +1,6 @@ +# align both = and // +my $color = $opts{'-color'} // 'black'; +my $background = $opts{'-background'} // 'none'; +my $linewidth = $opts{'-linewidth'} // 1; +my $radius = $opts{'-radius'} // 0; + diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 5476d1ab..c2f26eb2 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -83,6 +83,8 @@ ../snippets13.t align11.def ../snippets13.t align12.def ../snippets13.t align13.def +../snippets13.t rt127633.def +../snippets13.t rt127633.rt127633 ../snippets2.t angle.def ../snippets2.t arrows1.def ../snippets2.t arrows2.def @@ -243,5 +245,5 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets13.t rt127633.def -../snippets13.t rt127633.rt127633 +../snippets13.t align14.def +../snippets13.t align15.def diff --git a/t/snippets13.t b/t/snippets13.t index 8078edc6..af29e326 100644 --- a/t/snippets13.t +++ b/t/snippets13.t @@ -7,6 +7,8 @@ #4 align13.def #5 rt127633.def #6 rt127633.rt127633 +#7 align14.def +#8 align15.def # To locate test #13 you can search for its name or the string '#13' @@ -59,6 +61,22 @@ ok( $out !~ /EXACT /, "No 'baz'" ); ok( $out =~ //, "Got 'liz'" ); # liz ok( $out =~ //, "Got 'zoo'" ); # zoo ok( $out !~ //, "Got 'zap'" ); # zap +---------- + + 'align14' => <<'----------', +# align the = +my ($apple) = new Fruit( "Apple1", .1, .30 ); +my ($grapefruit) = new Grapefruit( "Grapefruit1", .3 ); +my ($redgrapefruit) = new RedGrapefruit( "Grapefruit2", .3 ); +---------- + + 'align15' => <<'----------', +# align both = and // +my$color=$opts{'-color'}//'black'; +my$background=$opts{'-background'}//'none'; +my$linewidth=$opts{'-linewidth'}//1; +my$radius=$opts{'-radius'}//0; + ---------- 'rt127633' => <<'----------', @@ -134,6 +152,30 @@ return $ref eq 'SCALAR' ? $self->encode_scalar( $object, $name, $type, $attr ) : $ref eq 'ARRAY'; #6........... }, + + 'align14.def' => { + source => "align14", + params => "def", + expect => <<'#7...........', +# align the = +my ($apple) = new Fruit( "Apple1", .1, .30 ); +my ($grapefruit) = new Grapefruit( "Grapefruit1", .3 ); +my ($redgrapefruit) = new RedGrapefruit( "Grapefruit2", .3 ); +#7........... + }, + + 'align15.def' => { + source => "align15", + params => "def", + expect => <<'#8...........', +# align both = and // +my $color = $opts{'-color'} // 'black'; +my $background = $opts{'-background'} // 'none'; +my $linewidth = $opts{'-linewidth'} // 1; +my $radius = $opts{'-radius'} // 0; + +#8........... + }, }; my $ntests = 0 + keys %{$rtests};