From c2737617ca09b3f808edd31ad2cda77616ff9b2e Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 19 Apr 2020 16:50:43 -0700 Subject: [PATCH] added tests for parameters -dbc -dp -dsc and -nibc --- t/snippets/comments.in | 32 ++++- t/snippets/comments1.par | 2 +- t/snippets/comments2.par | 2 +- t/snippets/comments5.par | 1 + t/snippets/expect/comments.comments1 | 31 ++++- t/snippets/expect/comments.comments2 | 20 ++- t/snippets/expect/comments.comments3 | 32 ++++- t/snippets/expect/comments.comments4 | 32 ++++- t/snippets/expect/comments.comments5 | 45 +++++++ t/snippets/expect/comments.def | 31 ++++- t/snippets/packing_list.txt | 45 +++---- t/snippets17.t | 182 +++++++++++++++++++++++++-- t/snippets18.t | 111 +++++++++++++++- 13 files changed, 518 insertions(+), 48 deletions(-) create mode 100644 t/snippets/comments5.par create mode 100644 t/snippets/expect/comments.comments5 diff --git a/t/snippets/comments.in b/t/snippets/comments.in index 3c57e797..9fa0ee35 100644 --- a/t/snippets/comments.in +++ b/t/snippets/comments.in @@ -1,8 +1,23 @@ -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length($_[0]) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # +# +# %name = macro_get_names(); (key=macrohandle, value=macroname) +# +##local(%name); # a static block comment + local(%name)=(); + for (0..$ #mac_ver) { + $name{$_} = $mac_ext[$idx{$mac_exti[$_]}]; + } + %name; +} + + # side comments at different indentation levels should not normally be aligned @@ -13,10 +28,23 @@ sub length { return length($_[0]) } # side comment - # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut diff --git a/t/snippets/comments1.par b/t/snippets/comments1.par index 24bda256..cd3c9861 100644 --- a/t/snippets/comments1.par +++ b/t/snippets/comments1.par @@ -1 +1 @@ --fpsc=40 -iscl +-fpsc=40 -iscl -nibc diff --git a/t/snippets/comments2.par b/t/snippets/comments2.par index 189d47bf..bf263e5b 100644 --- a/t/snippets/comments2.par +++ b/t/snippets/comments2.par @@ -1 +1 @@ --msc=10 +-msc=10 -dbc -dp diff --git a/t/snippets/comments5.par b/t/snippets/comments5.par new file mode 100644 index 00000000..52663e54 --- /dev/null +++ b/t/snippets/comments5.par @@ -0,0 +1 @@ +-dsc diff --git a/t/snippets/expect/comments.comments1 b/t/snippets/expect/comments.comments1 index 9c15f38b..5de00718 100644 --- a/t/snippets/expect/comments.comments1 +++ b/t/snippets/expect/comments.comments1 @@ -1,8 +1,22 @@ -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # +# +# %name = macro_get_names(); (key=macrohandle, value=macroname) +# +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + # side comments at different indentation levels should not normally be aligned { { @@ -16,3 +30,18 @@ sub length { return length( $_[0] ) } # side comment # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + diff --git a/t/snippets/expect/comments.comments2 b/t/snippets/expect/comments.comments2 index 3e6da005..da485912 100644 --- a/t/snippets/expect/comments.comments2 +++ b/t/snippets/expect/comments.comments2 @@ -1,9 +1,16 @@ -# test script for side comment and blank line flags +#!/usr/bin/perl -w sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment -# side comments at different indentation levels should not normally be aligned +sub macro_get_names { # + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + { { { @@ -14,5 +21,12 @@ sub length { return length( $_[0] ) } # side comment } # end level 2 } # end level 1 -# some blank lines follow + +__END__ + + +# text following __END__, not a comment + + + diff --git a/t/snippets/expect/comments.comments3 b/t/snippets/expect/comments.comments3 index e167541a..60b3059e 100644 --- a/t/snippets/expect/comments.comments3 +++ b/t/snippets/expect/comments.comments3 @@ -1,8 +1,22 @@ -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + # side comments at different indentation levels should not normally be aligned { @@ -19,3 +33,19 @@ sub length { return length( $_[0] ) } # side comment # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + diff --git a/t/snippets/expect/comments.comments4 b/t/snippets/expect/comments.comments4 index d69b7d88..0216c388 100644 --- a/t/snippets/expect/comments.comments4 +++ b/t/snippets/expect/comments.comments4 @@ -1,8 +1,23 @@ -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + + # side comments at different indentation levels should not normally be aligned @@ -18,10 +33,23 @@ sub length { return length( $_[0] ) } # side comment - # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut diff --git a/t/snippets/expect/comments.comments5 b/t/snippets/expect/comments.comments5 new file mode 100644 index 00000000..b21bbd17 --- /dev/null +++ b/t/snippets/expect/comments.comments5 @@ -0,0 +1,45 @@ +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp +sub length { return length( $_[0] ) } + +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + +# side comments at different indentation levels should not normally be aligned +{ + { + { + { + { ${msg} = "Hello World!"; print "My message: ${msg}\n"; } + } + } + } +} + +# some blank lines follow + +=pod +Some pod before __END__ to delete with -dp +=cut + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + diff --git a/t/snippets/expect/comments.def b/t/snippets/expect/comments.def index 18d14c73..883c68b1 100644 --- a/t/snippets/expect/comments.def +++ b/t/snippets/expect/comments.def @@ -1,8 +1,22 @@ -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + # side comments at different indentation levels should not normally be aligned { { @@ -16,3 +30,18 @@ sub length { return length( $_[0] ) } # side comment # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 818c1477..776266de 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -155,6 +155,28 @@ ../snippets16.t rt130394.rt130394 ../snippets16.t git18.def ../snippets16.t here2.def +../snippets17.t align32.def +../snippets17.t bos.bos +../snippets17.t bos.def +../snippets17.t comments.comments1 +../snippets17.t comments.comments2 +../snippets17.t comments.comments3 +../snippets17.t comments.comments4 +../snippets17.t comments.def +../snippets17.t long_line.def +../snippets17.t long_line.long_line +../snippets17.t pbp6.def +../snippets17.t pbp6.pbp +../snippets17.t rperl.def +../snippets17.t rperl.rperl +../snippets17.t rt132059.def +../snippets17.t rt132059.rt132059 +../snippets17.t signature.def +../snippets17.t ternary4.def +../snippets17.t wn7.def +../snippets18.t wn7.wn +../snippets18.t wn8.def +../snippets18.t wn8.wn ../snippets2.t angle.def ../snippets2.t arrows1.def ../snippets2.t arrows2.def @@ -315,25 +337,4 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets17.t align32.def -../snippets17.t bos.bos -../snippets17.t bos.def -../snippets17.t comments.comments1 -../snippets17.t comments.comments2 -../snippets17.t comments.comments3 -../snippets17.t comments.comments4 -../snippets17.t comments.def -../snippets17.t long_line.def -../snippets17.t long_line.long_line -../snippets17.t pbp6.def -../snippets17.t pbp6.pbp -../snippets17.t rperl.def -../snippets17.t rperl.rperl -../snippets17.t rt132059.def -../snippets17.t rt132059.rt132059 -../snippets17.t signature.def -../snippets17.t ternary4.def -../snippets17.t wn7.def -../snippets18.t wn7.wn -../snippets18.t wn8.def -../snippets18.t wn8.wn +../snippets18.t comments.comments5 diff --git a/t/snippets17.t b/t/snippets17.t index 2fed843a..c9cddd74 100644 --- a/t/snippets17.t +++ b/t/snippets17.t @@ -38,8 +38,8 @@ BEGIN { ########################################### $rparams = { 'bos' => "-bos", - 'comments1' => "-fpsc=40 -iscl", - 'comments2' => "-msc=10", + 'comments1' => "-fpsc=40 -iscl -nibc", + 'comments2' => "-msc=10 -dbc -dp", 'comments3' => "-mbl=2", 'comments4' => "-kbl=2", 'def' => "", @@ -67,11 +67,26 @@ ok IsWindow($c_sub_khwnd), 'IsWindow works on the client'; ---------- 'comments' => <<'----------', -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length($_[0]) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # +# +# %name = macro_get_names(); (key=macrohandle, value=macroname) +# +##local(%name); # a static block comment + local(%name)=(); + for (0..$ #mac_ver) { + $name{$_} = $mac_ext[$idx{$mac_exti[$_]}]; + } + %name; +} + + # side comments at different indentation levels should not normally be aligned @@ -82,11 +97,24 @@ sub length { return length($_[0]) } # side comment - # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut ---------- @@ -223,11 +251,25 @@ ok IsWindow($c_sub_khwnd), 'IsWindow works on the client'; source => "comments", params => "comments1", expect => <<'#4...........', -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # +# +# %name = macro_get_names(); (key=macrohandle, value=macroname) +# +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + # side comments at different indentation levels should not normally be aligned { { @@ -241,6 +283,21 @@ sub length { return length( $_[0] ) } # side comment # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + #4........... }, @@ -248,12 +305,19 @@ sub length { return length( $_[0] ) } # side comment source => "comments", params => "comments2", expect => <<'#5...........', -# test script for side comment and blank line flags +#!/usr/bin/perl -w sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment -# side comments at different indentation levels should not normally be aligned +sub macro_get_names { # + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + { { { @@ -264,7 +328,14 @@ sub length { return length( $_[0] ) } # side comment } # end level 2 } # end level 1 -# some blank lines follow + +__END__ + + +# text following __END__, not a comment + + + #5........... }, @@ -273,11 +344,25 @@ sub length { return length( $_[0] ) } # side comment source => "comments", params => "comments3", expect => <<'#6...........', -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + # side comments at different indentation levels should not normally be aligned { @@ -294,6 +379,22 @@ sub length { return length( $_[0] ) } # side comment # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + #6........... }, @@ -301,11 +402,26 @@ sub length { return length( $_[0] ) } # side comment source => "comments", params => "comments4", expect => <<'#7...........', -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + + # side comments at different indentation levels should not normally be aligned @@ -321,11 +437,24 @@ sub length { return length( $_[0] ) } # side comment - # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut #7........... @@ -335,11 +464,25 @@ sub length { return length( $_[0] ) } # side comment source => "comments", params => "def", expect => <<'#8...........', -# test script for side comment and blank line flags +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp sub length { return length( $_[0] ) } # side comment # hanging side comment # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + # side comments at different indentation levels should not normally be aligned { { @@ -353,6 +496,21 @@ sub length { return length( $_[0] ) } # side comment # some blank lines follow +=pod +Some pod before __END__ to delete with -dp +=cut + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + #8........... }, diff --git a/t/snippets18.t b/t/snippets18.t index b4b606e3..30d7ae35 100644 --- a/t/snippets18.t +++ b/t/snippets18.t @@ -4,6 +4,7 @@ #1 wn7.wn #2 wn8.def #3 wn8.wn +#4 comments.comments5 # To locate test #13 you can search for its name or the string '#13' @@ -21,8 +22,9 @@ BEGIN { # BEGIN SECTION 1: Parameter combinations # ########################################### $rparams = { - 'def' => "", - 'wn' => "-wn", + 'comments5' => "-dsc", + 'def' => "", + 'wn' => "-wn", }; ############################ @@ -30,6 +32,59 @@ BEGIN { ############################ $rsources = { + 'comments' => <<'----------', +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp +sub length { return length($_[0]) } # side comment + # hanging side comment + # very longgggggggggggggggggggggggggggggggggggggggggggggggggggg hanging side comment + +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { # +# +# %name = macro_get_names(); (key=macrohandle, value=macroname) +# +##local(%name); # a static block comment + local(%name)=(); + for (0..$ #mac_ver) { + $name{$_} = $mac_ext[$idx{$mac_exti[$_]}]; + } + %name; +} + + + + +# side comments at different indentation levels should not normally be aligned +{ { { { { ${msg} = "Hello World!"; print "My message: ${msg}\n"; } } #end level 4 + } # end level 3 + } # end level 2 +} # end level 1 + + + +# some blank lines follow + + + +=pod +Some pod before __END__ to delete with -dp +=cut + + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + +---------- + 'wn7' => <<'----------', # do not weld paren to opening one-line non-paren container $Self->_Add($SortOrderDisplay{$Field->GenerateFieldForSelectSQL()}); @@ -133,6 +188,58 @@ BEGIN { "Cannot delete zone $name: sub-zones or appellations exist.") ); #3........... }, + + 'comments.comments5' => { + source => "comments", + params => "comments5", + expect => <<'#4...........', +#!/usr/bin/perl -w +# an initial hash bang line cannot be deleted with -dp +sub length { return length( $_[0] ) } + +# side comments following open brace are not currently treated as hanging side comments +sub macro_get_names { + # + # %name = macro_get_names(); (key=macrohandle, value=macroname) + # +##local(%name); # a static block comment + local (%name) = (); + for ( 0 .. $#mac_ver ) { + $name{$_} = $mac_ext[ $idx{ $mac_exti[$_] } ]; + } + %name; +} + +# side comments at different indentation levels should not normally be aligned +{ + { + { + { + { ${msg} = "Hello World!"; print "My message: ${msg}\n"; } + } + } + } +} + +# some blank lines follow + +=pod +Some pod before __END__ to delete with -dp +=cut + +__END__ + + +# text following __END__, not a comment + + +=pod +Some pod after __END__ to delete with -dp +=cut + + +#4........... + }, }; my $ntests = 0 + keys %{$rtests}; -- 2.39.5