From: Steve Hancock Date: Tue, 7 Apr 2020 14:39:07 +0000 (-0700) Subject: complete coding for -bos option X-Git-Tag: 20200619~98 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a69c233beb696d70595f3255b7c16cc9056876be;p=perltidy.git complete coding for -bos option --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 54f03e53..663514fe 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -5977,14 +5977,16 @@ EOM Warn("Conflicting parameters: -iob and -boc; -boc will be ignored\n" ); } + if ( $rOpts->{'break-at-old-semicolon-breakpoints'} ) { + Warn("Conflicting parameters: -iob and -bos; -bos will be ignored\n" + ); + } # Note: there are additional parameters that can be made inactive by # -iob, but they are on by default so we would generate excessive # warnings if we noted them. They are: # $rOpts->{'break-at-old-keyword-breakpoints'} # $rOpts->{'break-at-old-logical-breakpoints'} - # $rOpts->{'break-at-old-method-breakpoints'} - # $rOpts->{'break-at-old-semicolon-breakpoints'} # $rOpts->{'break-at-old-ternary-breakpoints'} # $rOpts->{'break-at-old-attribute-breakpoints'} } @@ -15769,6 +15771,8 @@ sub sync_token_K { my $rOpts_short_concatenation_item_length = $rOpts->{'short-concatenation-item-length'}; + my $rOpts_break_at_old_semicolon_breakpoints = + $rOpts->{'break-at-old-semicolon-breakpoints'}; # Make a list of all good joining tokens between the lines # n-1 and n. @@ -15888,6 +15892,10 @@ sub sync_token_K { # do any special checks for it if ( $n == $nmax ) { + next + if ( $type_ibeg_2 eq ';' + && $rOpts_break_at_old_semicolon_breakpoints ); + # a terminal '{' should stay where it is # unless preceded by a fat comma next if ( $type_ibeg_2 eq '{' && $type_iend_1 ne '=>' ); diff --git a/t/snippets/bos.in b/t/snippets/bos.in new file mode 100644 index 00000000..3f5bae1d --- /dev/null +++ b/t/snippets/bos.in @@ -0,0 +1,2 @@ + $top_label->set_text( gettext("check permissions.") ) + ; diff --git a/t/snippets/bos.par b/t/snippets/bos.par new file mode 100644 index 00000000..da24ab34 --- /dev/null +++ b/t/snippets/bos.par @@ -0,0 +1 @@ +-bos diff --git a/t/snippets/expect/bos.bos b/t/snippets/expect/bos.bos new file mode 100644 index 00000000..3f5bae1d --- /dev/null +++ b/t/snippets/expect/bos.bos @@ -0,0 +1,2 @@ + $top_label->set_text( gettext("check permissions.") ) + ; diff --git a/t/snippets/expect/bos.def b/t/snippets/expect/bos.def new file mode 100644 index 00000000..c62a5c5d --- /dev/null +++ b/t/snippets/expect/bos.def @@ -0,0 +1 @@ + $top_label->set_text( gettext("check permissions.") ); diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 2fef0807..e0bc4d48 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -164,6 +164,8 @@ ../snippets17.t wn7.wn ../snippets17.t wn8.def ../snippets17.t wn8.wn +../snippets17.t pbp6.def +../snippets17.t pbp6.pbp ../snippets2.t angle.def ../snippets2.t arrows1.def ../snippets2.t arrows2.def @@ -324,5 +326,5 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets17.t pbp6.def -../snippets17.t pbp6.pbp +../snippets17.t bos.bos +../snippets17.t bos.def diff --git a/t/snippets17.t b/t/snippets17.t index c164d508..3daa35cc 100644 --- a/t/snippets17.t +++ b/t/snippets17.t @@ -12,6 +12,8 @@ #9 wn8.wn #10 pbp6.def #11 pbp6.pbp +#12 bos.bos +#13 bos.def # To locate test #13 you can search for its name or the string '#13' @@ -29,6 +31,7 @@ BEGIN { # BEGIN SECTION 1: Parameter combinations # ########################################### $rparams = { + 'bos' => "-bos", 'def' => "", 'pbp' => "-pbp -nst -nse", 'rperl' => "-l=0", @@ -41,6 +44,11 @@ BEGIN { ############################ $rsources = { + 'bos' => <<'----------', + $top_label->set_text( gettext("check permissions.") ) + ; +---------- + 'pbp6' => <<'----------', # These formerly blinked with -pbp return $width1*$common_length*( @@ -390,6 +398,23 @@ sub foo_subroutine_in_main { #11........... }, + + 'bos.bos' => { + source => "bos", + params => "bos", + expect => <<'#12...........', + $top_label->set_text( gettext("check permissions.") ) + ; +#12........... + }, + + 'bos.def' => { + source => "bos", + params => "def", + expect => <<'#13...........', + $top_label->set_text( gettext("check permissions.") ); +#13........... + }, }; my $ntests = 0 + keys %{$rtests};