From 1c531f014cbd37161ba79ad6fdeb056f092ee9fd Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 30 Nov 2018 17:45:49 -0800 Subject: [PATCH] added alignment test cases --- t/snippets/expect/iscl1.iscl | 4 +- t/snippets/packing_list.txt | 6 +++ t/snippets10.t | 20 ++++----- t/snippets13.t | 86 +++++++++++++++++++++++++++++++++++- t/snippets4.t | 4 +- 5 files changed, 104 insertions(+), 16 deletions(-) diff --git a/t/snippets/expect/iscl1.iscl b/t/snippets/expect/iscl1.iscl index 13595637..1465612f 100644 --- a/t/snippets/expect/iscl1.iscl +++ b/t/snippets/expect/iscl1.iscl @@ -1,4 +1,4 @@ # -iscl will not allow alignment of hanging side comments (currently) $gsmatch = ( $sub >= 50 ) ? "equal" : "lequal"; # Force an equal match for - # dev, but be more forgiving - # for releases + # dev, but be more forgiving + # for releases diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 4000e933..6a0c1e33 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -254,3 +254,9 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def +../snippets13.t align24.def +../snippets13.t align25.def +../snippets13.t align26.def +../snippets13.t align27.def +../snippets14.t else1.def +../snippets14.t else2.def diff --git a/t/snippets10.t b/t/snippets10.t index f7d153a3..f2b4b214 100644 --- a/t/snippets10.t +++ b/t/snippets10.t @@ -541,20 +541,20 @@ b_const ~~ a_const; [ keys %main:: ] ~~ \%::; \%:: ~~ []; [] ~~ \%::; -{ "" => 1 } ~~ [undef]; -[undef] ~~ { "" => 1 }; -{ foo => 1 } ~~ qr/^(fo[ox])$/; -qr/^(fo[ox])$/ ~~ { foo => 1 }; -+{ 0 .. 100 } ~~ qr/[13579]$/; -qr/[13579]$/ ~~ +{ 0 .. 100 }; +{ "" => 1 } ~~ [undef]; +[undef] ~~ { "" => 1 }; +{ foo => 1 } ~~ qr/^(fo[ox])$/; +qr/^(fo[ox])$/ ~~ { foo => 1 }; ++{ 0 .. 100 } ~~ qr/[13579]$/; +qr/[13579]$/ ~~ +{ 0 .. 100 }; +{ foo => 1, bar => 2 } ~~ "foo"; "foo" ~~ +{ foo => 1, bar => 2 }; +{ foo => 1, bar => 2 } ~~ "baz"; "baz" ~~ +{ foo => 1, bar => 2 }; -[] ~~ []; -[] ~~ []; -[] ~~ [1]; -[1] ~~ []; +[] ~~ []; +[] ~~ []; +[] ~~ [1]; +[1] ~~ []; [ ["foo"], ["bar"] ] ~~ [ qr/o/, qr/a/ ]; [ qr/o/, qr/a/ ] ~~ [ ["foo"], ["bar"] ]; [ "foo", "bar" ] ~~ [ qr/o/, qr/a/ ]; diff --git a/t/snippets13.t b/t/snippets13.t index c9a4f57b..eef4c949 100644 --- a/t/snippets13.t +++ b/t/snippets13.t @@ -16,6 +16,10 @@ #13 align21.def #14 align22.def #15 align23.def +#16 align24.def +#17 align25.def +#18 align26.def +#19 align27.def # To locate test #13 you can search for its name or the string '#13' @@ -124,6 +128,37 @@ $signum[$signal] = $_; # two equality lines with same pattern on left of equals will align my $orig = my $format = "^<<<<< ~~\n"; my $abc = "abc"; +---------- + + 'align24' => <<'----------', +# Do not align interior fat commas here; differnt container types +my $p = TAP::Parser::SubclassTest->new( + { + exec => [ $cat => $file ], + sources => { MySourceHandler => { accept_all => 1 } }, + } +); +---------- + + 'align25' => <<'----------', +# do not align commas here; different container types +is_deeply( [ $a, $a ], [ $b, $c ] ); +is_deeply( { foo => $a, bar => $a }, { foo => $b, bar => $c } ); +is_deeply( [ \$a, \$a ], [ \$b, \$c ] ); + +---------- + + 'align26' => <<'----------', +# align first of multiple equals +$SIG{PIPE}=sub{die"writingtoaclosedpipe"};#1= +$SIG{HUP}=$SIG{BREAK}=$SIG{INT}=$SIG{TERM};#3= +---------- + + 'align27' => <<'----------', +# do not align first equals here (unmatched commas on left side of =) +my ( $self, $name, $type ) = @_; +my $html_toc_fh = $self->{_html_toc_fh}; +my $html_prelim_fh = $self->{_html_prelim_fh}; ---------- 'break5' => <<'----------', @@ -175,8 +210,8 @@ my $account = "Insert into accountlines source => "align12", params => "def", expect => <<'#3...........', - my $type = shift || "o"; - my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' ); + my $type = shift || "o"; + my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' ); my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' ); #3........... }, @@ -322,6 +357,53 @@ my $orig = my $format = "^<<<<< ~~\n"; my $abc = "abc"; #15........... }, + + 'align24.def' => { + source => "align24", + params => "def", + expect => <<'#16...........', +# Do not align interior fat commas here; differnt container types +my $p = TAP::Parser::SubclassTest->new( + { + exec => [ $cat => $file ], + sources => { MySourceHandler => { accept_all => 1 } }, + } +); +#16........... + }, + + 'align25.def' => { + source => "align25", + params => "def", + expect => <<'#17...........', +# do not align commas here; different container types +is_deeply( [ $a, $a ], [ $b, $c ] ); +is_deeply( { foo => $a, bar => $a }, { foo => $b, bar => $c } ); +is_deeply( [ \$a, \$a ], [ \$b, \$c ] ); + +#17........... + }, + + 'align26.def' => { + source => "align26", + params => "def", + expect => <<'#18...........', +# align first of multiple equals +$SIG{PIPE} = sub { die "writingtoaclosedpipe" }; #1= +$SIG{HUP} = $SIG{BREAK} = $SIG{INT} = $SIG{TERM}; #3= +#18........... + }, + + 'align27.def' => { + source => "align27", + params => "def", + expect => <<'#19...........', +# do not align first equals here (unmatched commas on left side of =) +my ( $self, $name, $type ) = @_; +my $html_toc_fh = $self->{_html_toc_fh}; +my $html_prelim_fh = $self->{_html_prelim_fh}; +#19........... + }, }; my $ntests = 0 + keys %{$rtests}; diff --git a/t/snippets4.t b/t/snippets4.t index 0c5905a5..374e4c2b 100644 --- a/t/snippets4.t +++ b/t/snippets4.t @@ -475,8 +475,8 @@ else { $editlblk = "off"; $editlblkchecked = "unchecked" } expect => <<'#18...........', # -iscl will not allow alignment of hanging side comments (currently) $gsmatch = ( $sub >= 50 ) ? "equal" : "lequal"; # Force an equal match for - # dev, but be more forgiving - # for releases + # dev, but be more forgiving + # for releases #18........... }, -- 2.39.5