$alignment_type = $vert_last_nonblank_type;
}
-## #--------------------------------------------------------
-## # DEACTIVATED; DOES NOT SEEM NEEDED WITH NEW VERTICAL ALIGNER
-## # patch for =~ operator. We only align this if it
-## # is the first operator in a line, and the line is a simple
-## # statement. Aligning them within a statement
-## # could interfere with other good alignments.
-## #--------------------------------------------------------
-## if ( $alignment_type eq '=~' ) {
-## my $terminal_type = $types_to_go[$i_terminal];
-## if ( $count > 0 || $max_line > 0 || $terminal_type ne ';' )
-## {
-## $alignment_type = "";
-## }
-## }
+ #--------------------------------------------------------
+ # patch for =~ operator. We only align this if it
+ # is the first operator in a line, and the line is a simple
+ # statement. Aligning them within a statement
+ # could interfere with other good alignments.
+ #--------------------------------------------------------
+ if ( $alignment_type eq '=~' ) {
+ ##my $terminal_type = $types_to_go[$i_terminal];
+ ##if ( $count > 0 || $max_line > 0 || $terminal_type ne ';' )
+ ## TEMPORARY PATCH: allow =~ except in an 'elsif' statement
+ ## BUBBA FIXME: This prevents loss of padding in if/elsif lines, but the
+ ## Vertical aligner should be updated to handle this automatically.
+ ## Then this section can be removed
+ if ( $types_to_go[$ibeg] eq 'k'
+ && $tokens_to_go[$ibeg] eq 'elsif' )
+ {
+ $alignment_type = "";
+ }
+ }
#--------------------------------------------------------
# then store the value
#print "tok=$tok, lev=$lev, gl=$group_level, i=$i, ieq=$i_eq\n";
return if ( defined($i_eq) && $i < $i_eq );
- return if ( $lev >= $group_level );
+ return if ( $lev <= $group_level );
}
# most operators with an equals sign should be retained if at
--- /dev/null
+# alignment with lots of commas
+is( floor(1.23441242), 1, "Basic floor(1.23441242) test" );
+is( fmod( 3.5, 2.0 ), 1.5, "Basic fmod(3.5, 2.0) test" );
+is( join( " ", frexp(1) ), "0.5 1", "Basic frexp(1) test" );
+is( ldexp( 0, 1 ), 0, "Basic ldexp(0,1) test" );
+is( log10(1), 0, "Basic log10(1) test" );
--- /dev/null
+# commas on lhs align, commas on rhs do not (different subs)
+($x,$y,$z)=spherical_to_cartesian($rho,$theta,$phi);
+($rho_c,$theta,$z)=spherical_to_cylindrical($rho_s,$theta,$phi);
--- /dev/null
+# alignment with lots of commas
+is( floor(1.23441242), 1, "Basic floor(1.23441242) test" );
+is( fmod( 3.5, 2.0 ), 1.5, "Basic fmod(3.5, 2.0) test" );
+is( join( " ", frexp(1) ), "0.5 1", "Basic frexp(1) test" );
+is( ldexp( 0, 1 ), 0, "Basic ldexp(0,1) test" );
+is( log10(1), 0, "Basic log10(1) test" );
--- /dev/null
+# commas on lhs align, commas on rhs do not (different subs)
+( $x, $y, $z ) = spherical_to_cartesian( $rho, $theta, $phi );
+( $rho_c, $theta, $z ) = spherical_to_cylindrical( $rho_s, $theta, $phi );
# removed 'eq' and '=~' from alignment tokens to get alignment of '?'s
my $salute =
- $name eq $EMPTY_STR ? 'Customer'
+ $name eq $EMPTY_STR ? 'Customer'
: $name =~ m/\A((?:Sir|Dame) \s+ \S+) /xms ? $1
: $name =~ m/(.*), \s+ Ph[.]?D \z /xms ? "Dr $1"
: $name;
given ( [ 9, "a", 11 ] ) {
when (qr/\d/) {
given ($count) {
- when (1) { ok( $count == 1 ) }
- else { ok( $count != 1 ) }
+ when (1) { ok( $count == 1 ) }
+ else { ok( $count != 1 ) }
when ( [ 5, 6 ] ) { ok(0) }
- else { ok(1) }
+ else { ok(1) }
}
}
ok(1) when 11;
#!/usr/bin/perl -w
-use strict; # with -kgb, no break after hash bang
+use strict; # with -kgb, no break after hash bang
our ( @Changed, $TAP ); # break after isolated 'our'
use File::Compare;
use Symbol;
#!/usr/bin/perl -w
-use strict; # with -kgb, no break after hash bang
+use strict; # with -kgb, no break after hash bang
our ( @Changed, $TAP ); # break after isolated 'our'
use File::Compare;
my @sorted = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
- map { [ $_, rand ] } @list;
+ map { [ $_, rand ] } @list;
map { $_ => 'x' } keys %main::
}
~~ \%main::;
-\%hash ~~ \%tied_hash;
-\%tied_hash ~~ \%hash;
-\%tied_hash ~~ \%tied_hash;
-\%tied_hash ~~ \%tied_hash;
-\%:: ~~ [ keys %main:: ];
-[ keys %main:: ] ~~ \%::;
-\%:: ~~ [];
-[] ~~ \%::;
-{ "" => 1 } ~~ [undef];
-[undef] ~~ { "" => 1 };
-{ foo => 1 } ~~ qr/^(fo[ox])$/;
-qr/^(fo[ox])$/ ~~ { foo => 1 };
-+{ 0 .. 100 } ~~ qr/[13579]$/;
-qr/[13579]$/ ~~ +{ 0 .. 100 };
+\%hash ~~ \%tied_hash;
+\%tied_hash ~~ \%hash;
+\%tied_hash ~~ \%tied_hash;
+\%tied_hash ~~ \%tied_hash;
+\%:: ~~ [ keys %main:: ];
+[ keys %main:: ] ~~ \%::;
+\%:: ~~ [];
+[] ~~ \%::;
+{ "" => 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" ~~ +{ foo => 1, bar => 2 };
+{ foo => 1, bar => 2 } ~~ "baz";
-"baz" ~~ +{ foo => 1, bar => 2 };
-[] ~~ [];
-[] ~~ [];
-[] ~~ [1];
-[1] ~~ [];
+"baz" ~~ +{ foo => 1, bar => 2 };
+[] ~~ [];
+[] ~~ [];
+[] ~~ [1];
+[1] ~~ [];
[ ["foo"], ["bar"] ] ~~ [ qr/o/, qr/a/ ];
[ qr/o/, qr/a/ ] ~~ [ ["foo"], ["bar"] ];
[ "foo", "bar" ] ~~ [ qr/o/, qr/a/ ];
../snippets15.t break_old_methods.def
../snippets15.t bom1.bom
../snippets15.t bom1.def
+../snippets15.t align28.def
../snippets2.t angle.def
../snippets2.t arrows1.def
../snippets2.t arrows2.def
../snippets9.t rt98902.def
../snippets9.t rt98902.rt98902
../snippets9.t rt99961.def
-../snippets15.t align28.def
+../snippets15.t align29.def
+../snippets15.t align30.def
expect => <<'#5...........',
# removed 'eq' and '=~' from alignment tokens to get alignment of '?'s
my $salute =
- $name eq $EMPTY_STR ? 'Customer'
+ $name eq $EMPTY_STR ? 'Customer'
: $name =~ m/\A((?:Sir|Dame) \s+ \S+) /xms ? $1
: $name =~ m/(.*), \s+ Ph[.]?D \z /xms ? "Dr $1"
: $name;
map { $_ => 'x' } keys %main::
}
~~ \%main::;
-\%hash ~~ \%tied_hash;
-\%tied_hash ~~ \%hash;
-\%tied_hash ~~ \%tied_hash;
-\%tied_hash ~~ \%tied_hash;
-\%:: ~~ [ keys %main:: ];
-[ keys %main:: ] ~~ \%::;
-\%:: ~~ [];
-[] ~~ \%::;
-{ "" => 1 } ~~ [undef];
-[undef] ~~ { "" => 1 };
-{ foo => 1 } ~~ qr/^(fo[ox])$/;
-qr/^(fo[ox])$/ ~~ { foo => 1 };
-+{ 0 .. 100 } ~~ qr/[13579]$/;
-qr/[13579]$/ ~~ +{ 0 .. 100 };
+\%hash ~~ \%tied_hash;
+\%tied_hash ~~ \%hash;
+\%tied_hash ~~ \%tied_hash;
+\%tied_hash ~~ \%tied_hash;
+\%:: ~~ [ keys %main:: ];
+[ keys %main:: ] ~~ \%::;
+\%:: ~~ [];
+[] ~~ \%::;
+{ "" => 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" ~~ +{ foo => 1, bar => 2 };
+{ foo => 1, bar => 2 } ~~ "baz";
-"baz" ~~ +{ foo => 1, bar => 2 };
-[] ~~ [];
-[] ~~ [];
-[] ~~ [1];
-[1] ~~ [];
+"baz" ~~ +{ foo => 1, bar => 2 };
+[] ~~ [];
+[] ~~ [];
+[] ~~ [1];
+[1] ~~ [];
[ ["foo"], ["bar"] ] ~~ [ qr/o/, qr/a/ ];
[ qr/o/, qr/a/ ] ~~ [ ["foo"], ["bar"] ];
[ "foo", "bar" ] ~~ [ qr/o/, qr/a/ ];
params => "def",
expect => <<'#10...........',
#!/usr/bin/perl -w
-use strict; # with -kgb, no break after hash bang
+use strict; # with -kgb, no break after hash bang
our ( @Changed, $TAP ); # break after isolated 'our'
use File::Compare;
use Symbol;
params => "kgb",
expect => <<'#11...........',
#!/usr/bin/perl -w
-use strict; # with -kgb, no break after hash bang
+use strict; # with -kgb, no break after hash bang
our ( @Changed, $TAP ); # break after isolated 'our'
use File::Compare;
#8 bom1.bom
#9 bom1.def
#10 align28.def
+#11 align29.def
+#12 align30.def
# To locate test #13 you can search for its name or the string '#13'
if ( $a->{'abc'} eq 'ABC' ) { no_op(23) }
else { no_op(42) }
};
+----------
+
+ 'align29' => <<'----------',
+# alignment with lots of commas
+is( floor(1.23441242), 1, "Basic floor(1.23441242) test" );
+is( fmod( 3.5, 2.0 ), 1.5, "Basic fmod(3.5, 2.0) test" );
+is( join( " ", frexp(1) ), "0.5 1", "Basic frexp(1) test" );
+is( ldexp( 0, 1 ), 0, "Basic ldexp(0,1) test" );
+is( log10(1), 0, "Basic log10(1) test" );
+----------
+
+ 'align30' => <<'----------',
+# commas on lhs align, commas on rhs do not (different subs)
+($x,$y,$z)=spherical_to_cartesian($rho,$theta,$phi);
+($rho_c,$theta,$z)=spherical_to_cylindrical($rho_s,$theta,$phi);
----------
'bom1' => <<'----------',
};
#10...........
},
+
+ 'align29.def' => {
+ source => "align29",
+ params => "def",
+ expect => <<'#11...........',
+# alignment with lots of commas
+is( floor(1.23441242), 1, "Basic floor(1.23441242) test" );
+is( fmod( 3.5, 2.0 ), 1.5, "Basic fmod(3.5, 2.0) test" );
+is( join( " ", frexp(1) ), "0.5 1", "Basic frexp(1) test" );
+is( ldexp( 0, 1 ), 0, "Basic ldexp(0,1) test" );
+is( log10(1), 0, "Basic log10(1) test" );
+#11...........
+ },
+
+ 'align30.def' => {
+ source => "align30",
+ params => "def",
+ expect => <<'#12...........',
+# commas on lhs align, commas on rhs do not (different subs)
+( $x, $y, $z ) = spherical_to_cartesian( $rho, $theta, $phi );
+( $rho_c, $theta, $z ) = spherical_to_cylindrical( $rho_s, $theta, $phi );
+#12...........
+ },
};
my $ntests = 0 + keys %{$rtests};
given ( [ 9, "a", 11 ] ) {
when (qr/\d/) {
given ($count) {
- when (1) { ok( $count == 1 ) }
- else { ok( $count != 1 ) }
+ when (1) { ok( $count == 1 ) }
+ else { ok( $count != 1 ) }
when ( [ 5, 6 ] ) { ok(0) }
- else { ok(1) }
+ else { ok(1) }
}
}
ok(1) when 11;
expect => <<'#2...........',
my @sorted = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
- map { [ $_, rand ] } @list;
+ map { [ $_, rand ] } @list;
#2...........
},