From ec7d1c1c9fc86fcfcf8df4c1970ff933237cae37 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 10 Mar 2023 17:57:26 -0800 Subject: [PATCH] add tests b1452, b1453 --- dev-bin/run_convergence_tests.pl.data | 46 +++++++++++++++++++++++++ dev-bin/run_convergence_tests.pl.expect | 22 ++++++++++++ lib/Perl/Tidy/Formatter.pm | 14 ++++++-- 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 804e9538..91cd7a7c 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -11514,6 +11514,52 @@ my %distance_pref = --indent-columns=8 --want-trailing-commas='m' +==> b1453.in <== +my $foo =decode_json ( { + foo => 'bar' } ); + +my $foo + =decode_json ( { + foo => 'bar' + } ); + +==> b1453.par <== +--variable-maximum-line-length +--weld-nested-containers +--continuation-indentation=10 +--maximum-line-length=24 +--indent-columns=3 +--stack-opening-hash-brace +--vertical-tightness-closing=1 +--vertical-tightness=0 +--extended-line-up-parentheses +# These cancel each other: +#--nowant-right-space='=' +#--space-function-paren + +==> b1454.in <== +my $red_color = + $widget->window->get_colormap->color_alloc( + { + red => 65000, + green => 0, + blue => 0 + } + ); + +my $red_color = $widget->window->get_colormap->color_alloc( { + red => 65000, + green => 0, + blue => 0 +} ); + +==> b1454.par <== +--continuation-indentation=6 +--extended-line-up-parentheses +--maximum-line-length=66 +--variable-maximum-line-length +--weld-nested-containers + ==> b146.in <== # State 1 diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index 4b983994..3a5ece73 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -7812,6 +7812,28 @@ my %distance_pref = ); +==> b1453 <== +my $foo = decode_json( { + foo => 'bar' } ); + +my $foo = decode_json( { + foo => 'bar' } ); + +==> b1454 <== +my $red_color = + $widget->window->get_colormap->color_alloc( { + red => 65000, + green => 0, + blue => 0 + } ); + +my $red_color = + $widget->window->get_colormap->color_alloc( { + red => 65000, + green => 0, + blue => 0 + } ); + ==> b146 <== # State 1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index b762fa32..e4d3e68d 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -10626,8 +10626,16 @@ sub weld_nested_containers { # OLD: $single_line_tol added to fix cases b1180 b1181 # = $rOpts_continuation_indentation > $rOpts_indent_columns ? 1 : 0; - # NEW: $single_line_tol=0; fixes b1212 and b1180-1181 work now - my $single_line_tol = 0; + # NEW: $single_line_tol=0 fixes b1212; and b1180-1181 work ok now + # =1 for -vmll and -lp; fixes b1452, b1453, b1454 + # NOTE: the combination -vmll and -lp can be unstable, especially when + # also combined with -wn. It may eventually be necessary to turn off -vmll + # if -lp is set. For now, this works. The value '1' is a minimum which + # works but can be increased if necessary. + my $single_line_tol = + $rOpts_variable_maximum_line_length && $rOpts_line_up_parentheses + ? 1 + : 0; my $multiline_tol = $single_line_tol + 1 + max( $rOpts_indent_columns, $rOpts_continuation_indentation ); @@ -18289,7 +18297,7 @@ EOM # pass even if optimization is turned off for testing. # The OPTIMIZE_OK flag should be true except for testing. - use constant MAX_COMPARE_RATIO => 20; + use constant MAX_COMPARE_RATIO => DEVEL_MODE ? 3 : 20; use constant OPTIMIZE_OK => 1; my $num_pairs = $nend - $nbeg + 1; -- 2.39.5