Perl-Tidy

 view release on metacpan or  search on metacpan

t/snippets10.t  view on Meta::CPAN

-nsts
-sbt=2
-sbvt=1
-wls="= .= =~ !~ :"
-wrs="= .= =~ !~ ? :"
-ncsc
-isbc
-msc=2
-nolc
-bvt=1
-bl
-sbl
-pvt=1
-wba="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x= . << >> -> && ||"
-wbb=" "
-cab=1
-mbl=2
----------
    };

    ############################
    # BEGIN SECTION 2: Sources #
    ############################
    $rsources = {

        'scl' => <<'----------',
    # try -scl=12 to see '$returns' joined with the previous line
    $format = "format STDOUT =\n" . &format_line('Function:       @') . '$name' . "\n" . &format_line('Arguments:      @') . '$args' . "\n" . &format_line('Returns:        @') . '$returns' . "\n" . &format_line('             ~~ ^') . '$desc' . "\n.\n...
----------

        'semicolon2' => <<'----------',
	# will not add semicolon for this block type
        $highest = List::Util::reduce { Sort::Versions::versioncmp( $a, $b ) > 0 ? $a : $b }
----------

        'side_comments1' => <<'----------',
    # side comments at different indentation levels should not be aligned
    { { { { { ${msg} = "Hello World!"; print "My message: ${msg}\n"; } } #end level 4
            } # end level 3
        } # end level 2
    } # end level 1
----------

        'sil1' => <<'----------',
#############################################################
        # This will walk to the left because of bad -sil guess
      SKIP: {
#############################################################
        }

# This will walk to the right if it is the first line of a file.

     ov_method mycan( $package, '(""' ),       $package
  or ov_method mycan( $package, '(0+' ),       $package
  or ov_method mycan( $package, '(bool' ),     $package
  or ov_method mycan( $package, '(nomethod' ), $package;

----------

        'slashslash' => <<'----------',
$home = $ENV{HOME} // $ENV{LOGDIR} // ( getpwuid($<) )[7]
  // die "You're homeless!\n";
defined( $x // $y );
$version = 'v' . join '.', map ord, split //, $version->PV;
foreach ( split( //, $lets ) )  { }
foreach ( split( //, $input ) ) { }
'xyz' =~ //;
----------

        'smart' => <<'----------',
\&foo !~~ \&foo;
\&foo ~~ \&foo;
\&foo ~~ \&foo;
\&foo ~~ sub {};
sub {} ~~ \&foo;
\&foo ~~ \&bar;
\&bar ~~ \&foo;
1 ~~ sub{shift};
sub{shift} ~~ 1;
0 ~~ sub{shift};
sub{shift} ~~ 0;
1 ~~ sub{scalar @_};
sub{scalar @_} ~~ 1;
[] ~~ \&bar;
\&bar ~~ [];
{} ~~ \&bar;
\&bar ~~ {};
qr// ~~ \&bar;
\&bar ~~ qr//;
a_const ~~ "a constant";
"a constant" ~~ a_const;
a_const ~~ a_const;
a_const ~~ a_const;
a_const ~~ b_const;
b_const ~~ a_const;
{} ~~ {};
{} ~~ {};
{} ~~ {1 => 2};
{1 => 2} ~~ {};
{1 => 2} ~~ {1 => 2};
{1 => 2} ~~ {1 => 2};
{1 => 2} ~~ {1 => 3};
{1 => 3} ~~ {1 => 2};
{1 => 2} ~~ {2 => 3};
{2 => 3} ~~ {1 => 2};
\%main:: ~~ {map {$_ => 'x'} keys %main::};
{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};

t/snippets10.t  view on Meta::CPAN

            source => "side_comments1",
            params => "def",
            expect => <<'#4...........',
    # side comments at different indentation levels should not be aligned
    {
        {
            {
                {
                    { ${msg} = "Hello World!"; print "My message: ${msg}\n"; }
                }    #end level 4
            }    # end level 3
        }    # end level 2
    }    # end level 1
#4...........
        },

        'sil1.def' => {
            source => "sil1",
            params => "def",
            expect => <<'#5...........',
#############################################################
        # This will walk to the left because of bad -sil guess
      SKIP: {
#############################################################
        }

        # This will walk to the right if it is the first line of a file.

             ov_method mycan( $package, '(""' ),       $package
          or ov_method mycan( $package, '(0+' ),       $package
          or ov_method mycan( $package, '(bool' ),     $package
          or ov_method mycan( $package, '(nomethod' ), $package;

#5...........
        },

        'sil1.sil' => {
            source => "sil1",
            params => "sil",
            expect => <<'#6...........',
#############################################################
# This will walk to the left because of bad -sil guess
SKIP: {
#############################################################
}

# This will walk to the right if it is the first line of a file.

     ov_method mycan( $package, '(""' ),       $package
  or ov_method mycan( $package, '(0+' ),       $package
  or ov_method mycan( $package, '(bool' ),     $package
  or ov_method mycan( $package, '(nomethod' ), $package;

#6...........
        },

        'slashslash.def' => {
            source => "slashslash",
            params => "def",
            expect => <<'#7...........',
$home = $ENV{HOME} // $ENV{LOGDIR} // ( getpwuid($<) )[7]
  // die "You're homeless!\n";
defined( $x // $y );
$version = 'v' . join '.', map ord, split //, $version->PV;
foreach ( split( //, $lets ) )  { }
foreach ( split( //, $input ) ) { }
'xyz' =~ //;
#7...........
        },

        'smart.def' => {
            source => "smart",
            params => "def",
            expect => <<'#8...........',
\&foo !~~ \&foo;
\&foo             ~~ \&foo;
\&foo             ~~ \&foo;
\&foo             ~~ sub { };
sub { }           ~~ \&foo;
\&foo             ~~ \&bar;
\&bar             ~~ \&foo;
1                 ~~ sub { shift };
sub { shift }     ~~ 1;
0                 ~~ sub { shift };
sub { shift }     ~~ 0;
1                 ~~ sub { scalar @_ };
sub { scalar @_ } ~~ 1;
[]                ~~ \&bar;
\&bar             ~~ [];
{}                ~~ \&bar;
\&bar             ~~ {};
qr//              ~~ \&bar;
\&bar             ~~ qr//;
a_const           ~~ "a constant";
"a constant"      ~~ a_const;
a_const           ~~ a_const;
a_const           ~~ a_const;
a_const           ~~ b_const;
b_const           ~~ a_const;
{}                ~~ {};
{}                ~~ {};
{}                ~~ { 1 => 2 };
{ 1 => 2 }        ~~ {};
{ 1 => 2 } ~~ { 1 => 2 };
{ 1 => 2 } ~~ { 1 => 2 };
{ 1 => 2 } ~~ { 1 => 3 };
{ 1 => 3 } ~~ { 1 => 2 };
{ 1 => 2 } ~~ { 2 => 3 };
{ 2 => 3 } ~~ { 1 => 2 };
\%main:: ~~ { map { $_ => 'x' } keys %main:: };
{
    map { $_ => 'x' } keys %main::
}
~~ \%main::;
\%hash                  ~~ \%tied_hash;
\%tied_hash             ~~ \%hash;
\%tied_hash             ~~ \%tied_hash;
\%tied_hash             ~~ \%tied_hash;
\%::                    ~~ [ keys %main:: ];
[ keys %main:: ]        ~~ \%::;
\%::                    ~~ [];



( run in 3.296 seconds using v1.01-cache-2.11-cpan-5735350b133 )