]> git.donarmstrong.com Git - perltidy.git/commitdiff
add -btct test cases
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 3 Nov 2024 00:55:22 +0000 (17:55 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 3 Nov 2024 00:55:22 +0000 (17:55 -0700)
13 files changed:
MANIFEST
bin/perltidy
t/snippets/btct.in [new file with mode: 0644]
t/snippets/btct1.par [new file with mode: 0644]
t/snippets/btct2.par [new file with mode: 0644]
t/snippets/btct3.par [new file with mode: 0644]
t/snippets/expect/btct.btct1 [new file with mode: 0644]
t/snippets/expect/btct.btct2 [new file with mode: 0644]
t/snippets/expect/btct.btct3 [new file with mode: 0644]
t/snippets/expect/btct.def [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets30.t
t/snippets31.t [new file with mode: 0644]

index 0070037dcabaefff5e2749bbb4ac8294c5f5f7a5..479e3ab224efe3026634f9925f2993a8b0bd3ed7 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -79,6 +79,7 @@ t/snippets28.t
 t/snippets29.t
 t/snippets3.t
 t/snippets30.t
+t/snippets31.t
 t/snippets4.t
 t/snippets5.t
 t/snippets6.t
index 3ed9508d844f726e4aecd9b76c2b5d6048fe55a4..d3dd954a28368d1de4e10c0735ed1a83fd5b0239 100755 (executable)
@@ -4230,7 +4230,7 @@ we can add a trailing comma and break the container open with
         'g', Canvas => $overview_canvas,
     );
 
-After that, we could use -btct='f(b' to keep the container open
+After that, we could use C<-btct='f(b'> to keep the container open
 
 =item *
 
diff --git a/t/snippets/btct.in b/t/snippets/btct.in
new file mode 100644 (file)
index 0000000..43996da
--- /dev/null
@@ -0,0 +1,13 @@
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind( '<Page_Down>' => xx,);
+
+$w->bind(
+    '<Page_Down>' => xx
+);
+
+$w->bind( '<Page_Down>' => xx);
+
+$lut = byte [ [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ], ];
diff --git a/t/snippets/btct1.par b/t/snippets/btct1.par
new file mode 100644 (file)
index 0000000..7faeb11
--- /dev/null
@@ -0,0 +1 @@
+-btct=1
diff --git a/t/snippets/btct2.par b/t/snippets/btct2.par
new file mode 100644 (file)
index 0000000..970d0db
--- /dev/null
@@ -0,0 +1 @@
+-btct=1 -atc -wtc=1
diff --git a/t/snippets/btct3.par b/t/snippets/btct3.par
new file mode 100644 (file)
index 0000000..970d0db
--- /dev/null
@@ -0,0 +1 @@
+-btct=1 -atc -wtc=1
diff --git a/t/snippets/expect/btct.btct1 b/t/snippets/expect/btct.btct1
new file mode 100644 (file)
index 0000000..8896a78
--- /dev/null
@@ -0,0 +1,15 @@
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind( '<Page_Down>' => xx );
+
+$w->bind( '<Page_Down>' => xx );
+
+$lut = byte [
+    [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ],
+];
diff --git a/t/snippets/expect/btct.btct2 b/t/snippets/expect/btct.btct2
new file mode 100644 (file)
index 0000000..7ade862
--- /dev/null
@@ -0,0 +1,27 @@
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$lut = byte [
+    [
+        0, 0, 0,
+    ], [
+        10, 1, 10,
+    ], [
+        2, 20, 20,
+    ], [
+        30, 30, 3,
+    ],
+];
diff --git a/t/snippets/expect/btct.btct3 b/t/snippets/expect/btct.btct3
new file mode 100644 (file)
index 0000000..7ade862
--- /dev/null
@@ -0,0 +1,27 @@
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$lut = byte [
+    [
+        0, 0, 0,
+    ], [
+        10, 1, 10,
+    ], [
+        2, 20, 20,
+    ], [
+        30, 30, 3,
+    ],
+];
diff --git a/t/snippets/expect/btct.def b/t/snippets/expect/btct.def
new file mode 100644 (file)
index 0000000..7c97592
--- /dev/null
@@ -0,0 +1,9 @@
+$w->bind( '<Page_Down>' => xx, );
+
+$w->bind( '<Page_Down>' => xx, );
+
+$w->bind( '<Page_Down>' => xx );
+
+$w->bind( '<Page_Down>' => xx );
+
+$lut = byte [ [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ], ];
index febdba548526deeadec3442178670052c1ed106a..77f42a26c34400dcb22df6ab6733aa915c08ab1a 100644 (file)
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
+../snippets30.t        btct.btct1
+../snippets31.t        btct.btct2
+../snippets31.t        btct.btct3
+../snippets31.t        btct.def
index 3170b9726c4b2f388d192ce57323af2da886e7e1..66582f72e9d6780eaf0489a672ed5a2924e92a36 100644 (file)
@@ -19,6 +19,7 @@
 #16 git162.git162
 #17 qwaf.def
 #18 qwaf.qwaf
+#19 btct.btct1
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -38,6 +39,7 @@ BEGIN {
     $rparams = {
         'altc1'  => "-naltc -atc -wtc=m",
         'altc2'  => "-altc -atc -wtc=m",
+        'btct1'  => "-btct=1",
         'csc3'   => "-csc -csci=2 -ncscb",
         'def'    => "",
         'dltc1'  => "-dtc -wtc=0",
@@ -71,6 +73,22 @@ $self->make_grammar(
         version  => $self->version
     }
 );
+----------
+
+        'btct' => <<'----------',
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind( '<Page_Down>' => xx,);
+
+$w->bind(
+    '<Page_Down>' => xx
+);
+
+$w->bind( '<Page_Down>' => xx);
+
+$lut = byte [ [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ], ];
 ----------
 
         'csc' => <<'----------',
@@ -486,6 +504,28 @@ use Digest::MD5 qw(md5_hex);
 @list = qw( \ );
 #18...........
         },
+
+        'btct.btct1' => {
+            source => "btct",
+            params => "btct1",
+            expect => <<'#19...........',
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind( '<Page_Down>' => xx );
+
+$w->bind( '<Page_Down>' => xx );
+
+$lut = byte [
+    [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ],
+];
+#19...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};
diff --git a/t/snippets31.t b/t/snippets31.t
new file mode 100644 (file)
index 0000000..27f5421
--- /dev/null
@@ -0,0 +1,199 @@
+# Created with: ./make_t.pl
+
+# Contents:
+#1 btct.btct2
+#2 btct.btct3
+#3 btct.def
+
+# To locate test #13 you can search for its name or the string '#13'
+
+use strict;
+use Test::More;
+use Carp;
+use Perl::Tidy;
+my $rparams;
+my $rsources;
+my $rtests;
+
+BEGIN {
+
+    ###########################################
+    # BEGIN SECTION 1: Parameter combinations #
+    ###########################################
+    $rparams = {
+        'btct2' => "-btct=1 -atc -wtc=1",
+        'btct3' => "-btct=1 -atc -wtc=1",
+        'def'   => "",
+    };
+
+    ############################
+    # BEGIN SECTION 2: Sources #
+    ############################
+    $rsources = {
+
+        'btct' => <<'----------',
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind( '<Page_Down>' => xx,);
+
+$w->bind(
+    '<Page_Down>' => xx
+);
+
+$w->bind( '<Page_Down>' => xx);
+
+$lut = byte [ [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ], ];
+----------
+    };
+
+    ####################################
+    # BEGIN SECTION 3: Expected output #
+    ####################################
+    $rtests = {
+
+        'btct.btct2' => {
+            source => "btct",
+            params => "btct2",
+            expect => <<'#1...........',
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$lut = byte [
+    [
+        0, 0, 0,
+    ], [
+        10, 1, 10,
+    ], [
+        2, 20, 20,
+    ], [
+        30, 30, 3,
+    ],
+];
+#1...........
+        },
+
+        'btct.btct3' => {
+            source => "btct",
+            params => "btct3",
+            expect => <<'#2...........',
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$w->bind(
+    '<Page_Down>' => xx,
+);
+
+$lut = byte [
+    [
+        0, 0, 0,
+    ], [
+        10, 1, 10,
+    ], [
+        2, 20, 20,
+    ], [
+        30, 30, 3,
+    ],
+];
+#2...........
+        },
+
+        'btct.def' => {
+            source => "btct",
+            params => "def",
+            expect => <<'#3...........',
+$w->bind( '<Page_Down>' => xx, );
+
+$w->bind( '<Page_Down>' => xx, );
+
+$w->bind( '<Page_Down>' => xx );
+
+$w->bind( '<Page_Down>' => xx );
+
+$lut = byte [ [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ], ];
+#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 ) {
+        print STDERR "Error output received for test '$key'\n";
+        if ($err) {
+            print STDERR "An error flag '$err' was returned\n";
+            ok( !$err );
+        }
+        if ($stderr_string) {
+            print STDERR "---------------------\n";
+            print STDERR "<<STDERR>>\n$stderr_string\n";
+            print STDERR "---------------------\n";
+            ok( !$stderr_string );
+        }
+        if ($errorfile_string) {
+            print STDERR "---------------------\n";
+            print STDERR "<<.ERR file>>\n$errorfile_string\n";
+            print STDERR "---------------------\n";
+            ok( !$errorfile_string );
+        }
+    }
+    else {
+        if ( !is( $output, $expect, $key ) ) {
+            my $leno = length($output);
+            my $lene = length($expect);
+            if ( $leno == $lene ) {
+                print STDERR
+"#> Test '$key' gave unexpected output.  Strings differ but both have length $leno\n";
+            }
+            else {
+                print STDERR
+"#> Test '$key' gave unexpected output.  String lengths differ: output=$leno, expected=$lene\n";
+            }
+        }
+    }
+}