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
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
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
--- /dev/null
+# align the =
+my ($apple) = new Fruit( "Apple1", .1, .30 );
+my ($grapefruit) = new Grapefruit( "Grapefruit1", .3 );
+my ($redgrapefruit) = new RedGrapefruit( "Grapefruit2", .3 );
--- /dev/null
+# align both = and //
+my$color=$opts{'-color'}//'black';
+my$background=$opts{'-background'}//'none';
+my$linewidth=$opts{'-linewidth'}//1;
+my$radius=$opts{'-radius'}//0;
+
--- /dev/null
+# align the =
+my ($apple) = new Fruit( "Apple1", .1, .30 );
+my ($grapefruit) = new Grapefruit( "Grapefruit1", .3 );
+my ($redgrapefruit) = new RedGrapefruit( "Grapefruit2", .3 );
--- /dev/null
+# align both = and //
+my $color = $opts{'-color'} // 'black';
+my $background = $opts{'-background'} // 'none';
+my $linewidth = $opts{'-linewidth'} // 1;
+my $radius = $opts{'-radius'} // 0;
+
../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
../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
#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'
ok( $out =~ /<liz>/, "Got 'liz'" ); # liz
ok( $out =~ /<zoo>/, "Got 'zoo'" ); # zoo
ok( $out !~ /<zap>/, "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' => <<'----------',
$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};