]> git.donarmstrong.com Git - perltidy.git/commitdiff
added alignment test snippets
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 13 Nov 2018 22:42:49 +0000 (14:42 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 13 Nov 2018 22:42:49 +0000 (14:42 -0800)
t/snippets/README.md
t/snippets/align14.in [new file with mode: 0644]
t/snippets/align15.in [new file with mode: 0644]
t/snippets/expect/align14.def [new file with mode: 0644]
t/snippets/expect/align15.def [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets13.t

index 65878325d33663e05be950ce21a9c5d989d3064c..b6b75710c821df472f253cade0100f89380ce8ab 100644 (file)
@@ -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 (file)
index 0000000..198968a
--- /dev/null
@@ -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 (file)
index 0000000..05c17bb
--- /dev/null
@@ -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 (file)
index 0000000..198968a
--- /dev/null
@@ -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 (file)
index 0000000..16089f4
--- /dev/null
@@ -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;
+
index 5476d1abef41da0bb3cb5bd5cbde446cb95be99a..c2f26eb23f47fe21a7b6ac056e937d3ca48eee4e 100644 (file)
@@ -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
 ../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
index 8078edc67dc892dad773e08d23c84371b15f92e9..af29e326596b9b27dd4eb7166fc8b3b7be62951e 100644 (file)
@@ -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 <fop>/, "No 'baz'" );
 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' => <<'----------',
@@ -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};