Perl-Tidy
view release on metacpan or search on metacpan
t/snippets20.t view on Meta::CPAN
BEGIN {
###########################################
# BEGIN SECTION 1: Parameter combinations #
###########################################
$rparams = {
'ce' => "-cuddled-blocks",
'def' => "",
'git25' => "-l=0",
'gnu' => "-gnu",
'kpit' => "-pt=2 -kpit=0",
'kpitl' => <<'----------',
-kpit=0 -kpitl='return factorial' -pt=2
----------
'outdent2' => <<'----------',
# test -okw and -okwl
-okw -okwl='next'
----------
'space6' => <<'----------',
-nwrs="+ - / *"
-nwls="+ - / *"
----------
'wc1' => "-wc=4",
'wc2' => "-wc=4 -wn",
};
############################
# BEGIN SECTION 2: Sources #
############################
$rsources = {
'ce2' => <<'----------',
# Previously, perltidy -ce would move a closing brace below a pod section to
# form '} else {'. No longer doing this because if you change back to -nce, the
# brace cannot go back to where it was.
if ($notty) {
$runnonstop = 1;
share($runnonstop);
}
=pod
If there is a TTY, we have to determine who it belongs to before we can
...
=cut
else {
# Is Perl being run from a slave editor or graphical debugger?
...
}
----------
'git25' => <<'----------',
# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this
my $mapping = [
# ...
{ 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, },
{ 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, },
{ 'is_col' => 'symptoms_fever', 'cr_col' => 'elig_fever', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, },
{ 'is_col' => 'symptoms_cough', 'cr_col' => 'elig_cough', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, },
{ 'is_col' => 'symptoms_dys_tachy_noea', 'cr_col' => 'elig_dyspnea', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, },
{ 'is_col' => 'symptoms_clinical_susp', 'cr_col' => 'elig_ari', 'trans' => 0, },
{ 'is_col' => 'sex', 'cr_col' => 'sex', 'trans' => 1, 'manually_reviewed' => 1, 'map' => { '0' => '1', '1' => '2' }, },
{ 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, },
{ 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, },
# ...
];
----------
'gnu6' => <<'----------',
# These closing braces no longer have the same position with -gnu after an
# update 13 dec 2021 in which the vertical aligner zeros recoverable spaces.
# But adding the -xlp should make them all have the same indentation.
$var1 = {
'foo10' => undef,
'foo72' => ' ',
};
$var1 = {
'foo10' => undef,
'foo72' => '
',
};
$var2 = {
'foo72' => '
',
'foo10' => undef,
};
----------
'hanging_side_comments3' => <<'----------',
if ( $var eq 'wastebasket' ) { # this sends a pure block
# of hanging side comments
#to the vertical aligner.
#It caused a crash in
#a test version of
#sub 'delete_unmatched_tokens'
#...
#}
}
elsif ( $var eq 'spacecommand' ) {
&die("No $val function") unless eval "defined &$val";
}
----------
'kpit' => <<'----------',
if ( seek(DATA, 0, 0) ) { ... }
# The foreach keyword may be separated from the next opening paren
foreach $req(@bgQueue) {
...
}
# This had trouble because a later padding operation removed the inside space
while ($CmdJob eq "" && @CmdQueue > 0 && $RunNightlyWhenIdle != 1
|| @CmdQueue > 0 && $RunNightlyWhenIdle == 2 && $bpc->isAdminJob($CmdQueue[0]->{host})) {
...
}
t/snippets20.t view on Meta::CPAN
#8...........
},
'gnu6.def' => {
source => "gnu6",
params => "def",
expect => <<'#9...........',
# These closing braces no longer have the same position with -gnu after an
# update 13 dec 2021 in which the vertical aligner zeros recoverable spaces.
# But adding the -xlp should make them all have the same indentation.
$var1 = {
'foo10' => undef,
'foo72' => ' ',
};
$var1 = {
'foo10' => undef,
'foo72' => '
',
};
$var2 = {
'foo72' => '
',
'foo10' => undef,
};
#9...........
},
'gnu6.gnu' => {
source => "gnu6",
params => "gnu",
expect => <<'#10...........',
# These closing braces no longer have the same position with -gnu after an
# update 13 dec 2021 in which the vertical aligner zeros recoverable spaces.
# But adding the -xlp should make them all have the same indentation.
$var1 = {
'foo10' => undef,
'foo72' => ' ',
};
$var1 = {
'foo10' => undef,
'foo72' => '
',
};
$var2 = {
'foo72' => '
',
'foo10' => undef,
};
#10...........
},
'git25.def' => {
source => "git25",
params => "def",
expect => <<'#11...........',
# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this
my $mapping = [
# ...
{ 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, },
{ 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, },
{
'is_col' => 'symptoms_fever',
'cr_col' => 'elig_fever',
'trans' => 1,
'manually_reviewed' => '@TODO',
'map' => { '0' => '0', '1' => '1', '9' => '@TODO' },
},
{
'is_col' => 'symptoms_cough',
'cr_col' => 'elig_cough',
'trans' => 1,
'manually_reviewed' => '@TODO',
'map' => { '0' => '0', '1' => '1', '9' => '@TODO' },
},
{
'is_col' => 'symptoms_dys_tachy_noea',
'cr_col' => 'elig_dyspnea',
'trans' => 1,
'manually_reviewed' => '@TODO',
'map' => { '0' => '0', '1' => '1', '9' => '@TODO' },
},
{
'is_col' => 'symptoms_clinical_susp',
'cr_col' => 'elig_ari',
'trans' => 0,
},
{
'is_col' => 'sex',
'cr_col' => 'sex',
'trans' => 1,
'manually_reviewed' => 1,
'map' => { '0' => '1', '1' => '2' },
},
{ 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, },
{ 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, },
# ...
];
#11...........
},
'git25.git25' => {
source => "git25",
params => "git25",
expect => <<'#12...........',
# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this
my $mapping = [
# ...
{ 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, },
{ 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, },
{ 'is_col' => 'symptoms_fever', 'cr_col' => 'elig_fever', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, },
{ 'is_col' => 'symptoms_cough', 'cr_col' => 'elig_cough', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, },
{ 'is_col' => 'symptoms_dys_tachy_noea', 'cr_col' => 'elig_dyspnea', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, },
{ 'is_col' => 'symptoms_clinical_susp', 'cr_col' => 'elig_ari', 'trans' => 0, },
{ 'is_col' => 'sex', 'cr_col' => 'sex', 'trans' => 1, 'manually_reviewed' => 1, 'map' => { '0' => '1', '1' => '2' }, },
{ 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, },
{ 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, },
# ...
];
#12...........
},
'outdent.outdent2' => {
source => "outdent",
params => "outdent2",
expect => <<'#13...........',
my $i;
LOOP: while ( $i = <FOTOS> ) {
chomp($i);
next unless $i;
fixit($i);
}
#13...........
},
'kpit.def' => {
source => "kpit",
params => "def",
expect => <<'#14...........',
if ( seek( DATA, 0, 0 ) ) { ... }
# The foreach keyword may be separated from the next opening paren
foreach $req (@bgQueue) {
...;
}
# This had trouble because a later padding operation removed the inside space
while ($CmdJob eq "" && @CmdQueue > 0 && $RunNightlyWhenIdle != 1
|| @CmdQueue > 0
&& $RunNightlyWhenIdle == 2
&& $bpc->isAdminJob( $CmdQueue[0]->{host} ) )
{
...;
}
#14...........
},
'kpit.kpit' => {
source => "kpit",
params => "kpit",
expect => <<'#15...........',
if ( seek(DATA, 0, 0) ) { ... }
# The foreach keyword may be separated from the next opening paren
foreach $req ( @bgQueue ) {
...;
( run in 1.104 second using v1.01-cache-2.11-cpan-df04353d9ac )