From 28f52bea533e3637699e4c4146e842efc5daedbe Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 16 Nov 2018 16:03:12 -0800 Subject: [PATCH] fixed rt127633 --- lib/Perl/Tidy/Formatter.pm | 11 +++++++++-- t/snippets/expect/math4.def | 3 +-- t/snippets/expect/pbp1.def | 3 +-- t/snippets/expect/rt127633.def | 4 +++- t/snippets/expect/rt127633.rt127633 | 4 +++- t/snippets/packing_list.txt | 4 ++-- t/snippets/rt127633.in | 3 ++- t/snippets/rt127633.par | 2 +- t/snippets13.t | 15 +++++++++------ t/snippets5.t | 3 +-- t/snippets6.t | 3 +-- 11 files changed, 33 insertions(+), 22 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index e8ea6b4a..4e50c2ed 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -14823,8 +14823,15 @@ sub undo_forced_breakpoint_stack { # do not recombine if the two lines might align well # this is a very approximate test for this - && ( $ibeg_3 >= 0 - && $type_ibeg_2 ne $types_to_go[$ibeg_3] ) + && ( + + # RT#127633 - the leading tokens are not operators + ( $type_ibeg_2 ne $tokens_to_go[$ibeg_2] ) + + # or they are different + || ( $ibeg_3 >= 0 + && $type_ibeg_2 ne $types_to_go[$ibeg_3] ) + ) ); if ( diff --git a/t/snippets/expect/math4.def b/t/snippets/expect/math4.def index 1620dca5..f4566b27 100644 --- a/t/snippets/expect/math4.def +++ b/t/snippets/expect/math4.def @@ -1,7 +1,6 @@ my $u = ( $range * $pratio**( 1. / 3. ) ) / $wratio; my $factor = exp( -( 18 / $u )**4 ); -my $ovp = - ( 1 - $factor ) * ( 70 - 0.655515 * $u ) + +my $ovp = ( 1 - $factor ) * ( 70 - 0.655515 * $u ) + ( 1000 / ( $u**1.3 ) + 10000 / ( $u**3.3 ) ) * $factor; my $impulse = ( 1 - $factor ) * ( 170 - $u ) + ( 350 / $u**0.65 + 500 / $u**5 ) * $factor; diff --git a/t/snippets/expect/pbp1.def b/t/snippets/expect/pbp1.def index 682ecce5..fa4cb340 100644 --- a/t/snippets/expect/pbp1.def +++ b/t/snippets/expect/pbp1.def @@ -1,4 +1,3 @@ # break after '+' if default, before + if pbp - my $min_gnu_indentation = - $standard_increment + + my $min_gnu_indentation = $standard_increment + $gnu_stack[$max_gnu_stack_index]->get_SPACES(); diff --git a/t/snippets/expect/rt127633.def b/t/snippets/expect/rt127633.def index c7ee4ef4..7666b103 100644 --- a/t/snippets/expect/rt127633.def +++ b/t/snippets/expect/rt127633.def @@ -1,4 +1,6 @@ -# do not break after return with -wba=':' +# keep lines long; do not break after 'return' and '.' with -baoo return $ref eq 'SCALAR' ? $self->encode_scalar( $object, $name, $type, $attr ) : $ref eq 'ARRAY'; +my $s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + . 'bbbbbbbbbbbbbbbbbbbbbbbbb'; diff --git a/t/snippets/expect/rt127633.rt127633 b/t/snippets/expect/rt127633.rt127633 index eed8d0e6..df3510cf 100644 --- a/t/snippets/expect/rt127633.rt127633 +++ b/t/snippets/expect/rt127633.rt127633 @@ -1,3 +1,5 @@ -# do not break after return with -wba=':' +# keep lines long; do not break after 'return' and '.' with -baoo return $ref eq 'SCALAR' ? $self->encode_scalar( $object, $name, $type, $attr ) : $ref eq 'ARRAY'; +my $s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' . + 'bbbbbbbbbbbbbbbbbbbbbbbbb'; diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 75ab8b24..4000e933 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -92,6 +92,8 @@ ../snippets13.t align19.def ../snippets13.t align20.def ../snippets13.t align21.def +../snippets13.t align22.def +../snippets13.t align23.def ../snippets2.t angle.def ../snippets2.t arrows1.def ../snippets2.t arrows2.def @@ -252,5 +254,3 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets13.t align22.def -../snippets13.t align23.def diff --git a/t/snippets/rt127633.in b/t/snippets/rt127633.in index 0f9e1433..8ea28267 100644 --- a/t/snippets/rt127633.in +++ b/t/snippets/rt127633.in @@ -1,2 +1,3 @@ -# do not break after return with -wba=':' +# keep lines long; do not break after 'return' and '.' with -baoo return $ref eq 'SCALAR' ? $self->encode_scalar( $object, $name, $type, $attr ) : $ref eq 'ARRAY'; +my $s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' . 'bbbbbbbbbbbbbbbbbbbbbbbbb'; diff --git a/t/snippets/rt127633.par b/t/snippets/rt127633.par index 8125ee4c..14931b3b 100644 --- a/t/snippets/rt127633.par +++ b/t/snippets/rt127633.par @@ -1 +1 @@ --wba=':' +-baao diff --git a/t/snippets13.t b/t/snippets13.t index b731cdde..139927d1 100644 --- a/t/snippets13.t +++ b/t/snippets13.t @@ -34,9 +34,7 @@ BEGIN { ########################################### $rparams = { 'def' => "", - 'rt127633' => <<'----------', --wba=':' ----------- + 'rt127633' => "-baao", }; ############################ @@ -142,8 +140,9 @@ return ( ---------- 'rt127633' => <<'----------', -# do not break after return with -wba=':' +# keep lines long; do not break after 'return' and '.' with -baoo return $ref eq 'SCALAR' ? $self->encode_scalar( $object, $name, $type, $attr ) : $ref eq 'ARRAY'; +my $s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' . 'bbbbbbbbbbbbbbbbbbbbbbbbb'; ---------- }; @@ -198,10 +197,12 @@ ok( $out !~ //, "Got 'zap'" ); # zap source => "rt127633", params => "def", expect => <<'#5...........', -# do not break after return with -wba=':' +# keep lines long; do not break after 'return' and '.' with -baoo return $ref eq 'SCALAR' ? $self->encode_scalar( $object, $name, $type, $attr ) : $ref eq 'ARRAY'; +my $s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + . 'bbbbbbbbbbbbbbbbbbbbbbbbb'; #5........... }, @@ -209,9 +210,11 @@ return $ref eq 'SCALAR' source => "rt127633", params => "rt127633", expect => <<'#6...........', -# do not break after return with -wba=':' +# keep lines long; do not break after 'return' and '.' with -baoo return $ref eq 'SCALAR' ? $self->encode_scalar( $object, $name, $type, $attr ) : $ref eq 'ARRAY'; +my $s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' . + 'bbbbbbbbbbbbbbbbbbbbbbbbb'; #6........... }, diff --git a/t/snippets5.t b/t/snippets5.t index 3279c825..f65be6ec 100644 --- a/t/snippets5.t +++ b/t/snippets5.t @@ -853,8 +853,7 @@ $ans = pdl( expect => <<'#15...........', my $u = ( $range * $pratio**( 1. / 3. ) ) / $wratio; my $factor = exp( -( 18 / $u )**4 ); -my $ovp = - ( 1 - $factor ) * ( 70 - 0.655515 * $u ) + +my $ovp = ( 1 - $factor ) * ( 70 - 0.655515 * $u ) + ( 1000 / ( $u**1.3 ) + 10000 / ( $u**3.3 ) ) * $factor; my $impulse = ( 1 - $factor ) * ( 170 - $u ) + ( 350 / $u**0.65 + 500 / $u**5 ) * $factor; diff --git a/t/snippets6.t b/t/snippets6.t index 0e1e00f1..4836fffc 100644 --- a/t/snippets6.t +++ b/t/snippets6.t @@ -186,8 +186,7 @@ return $pdl->slice( params => "def", expect => <<'#2...........', # break after '+' if default, before + if pbp - my $min_gnu_indentation = - $standard_increment + + my $min_gnu_indentation = $standard_increment + $gnu_stack[$max_gnu_stack_index]->get_SPACES(); #2........... }, -- 2.39.5