PerlPowerTools
view release on metacpan or search on metacpan
}
push @fields, [$2, $3 - 1];
}
}
} while (length || (@ARGV && $ARGV[0] =~ m!^0$|^[12]\.\d+$!));
}
sub get_options {
my ($aflag, $vflag);
while (@ARGV && $ARGV[0] =~ /^-(.)/) {
local $_ = shift @ARGV;
return if $_ eq '--';
if (s/^-a//) {
help() if $vflag;
$aflag = 1;
my $f = get_file_number('a');
$unpairables[$f] = 1;
}
elsif (s/^-v//) {
help() if $aflag;
$vflag = 1;
return $class->VERSION_MESSAGE if exists $original_positions{'version'};
return $class->usage(
-verbose => 2,
-output => $class->error_fh,
) if exists $original_positions{'help'};
my $opts_string = $class->_opts_string;
local $Getopt::Std::STANDARD_HELP_VERSION = 1;
local @ARGV = @args;
unless( Getopt::Std::getopts($opts_string, $Options) ) {
$class->my_warn( "usage: " . PROGRAM . " [-$opts_string] [file ...]", 0 );
$class->my_exit( EX_FAILURE );
}
@args = @ARGV;
my %Defaults = ( w => $class->get_columns );
foreach my $key ( keys %Defaults ) {
next if defined $Options->{$key};
if ($_ eq '+') {
push @options, [splice @opts, 0];
} else {
push @opts, $_;
}
}
# Parse each set of options into a hash.
my $next = 0;
for (@options) {
local @ARGV = @$_;
my %opts;
Getopt::Long::GetOptions(\%opts, @desc) or die("Bad options\n");
type_conflict(\%opts);
ifdef_id_check($opts{'ifdef'}) if defined $opts{'ifdef'};
$opts{origfile} = shift;
$_ = \%opts;
$patchfile = shift unless $next++;
version() if $opts{'version'};
}
}
zepto => 15,
yocto => 18,
);
$PREF = join '|', sort {$PREF{$a} <=> $PREF{$b}} (keys %PREF);
}
# run if called directly, indirectly, directly par-packed, undirectly par-packed
__PACKAGE__->run(@ARGV) if !caller() || caller(0) =~ /^(PerlPowerTools::Packed|PAR)$/ || caller(1) eq 'PAR'; # modulino
sub run {
my( $class, @args ) = @_; local @ARGV;
my $args = $class->process_args( @args );
$class->read_unittab( $args->{unittabs}[0] );
if (@{ $args->{args} }) {
my ($have, $want) = @{ $args->{args} };
my $have_hr = $class->unit_have($have);
my $want_hr = $class->unit_want($want);
my %r = $class->unit_convert($have_hr, $want_hr);
t/rev/rev.t view on Meta::CPAN
compiles_ok( $command );
};
subtest "from file" => sub {
my $file = catfile( qw(t data rev reverse-this.txt) );
ok( -e $file, "Test file <$file> exists" );
ok( -r $file, "Test file <$file> is readable" );
my $expected = join '',
map { chomp; reverse($_) . "\n" }
do { local @ARGV = $file; <> };
my( $input, $output, $error );
my @command = ( $^X, $command, $file );
run3 \@command, \$input, \$output, \$error;
is $output, $expected, "output has the lines reversed";
};
subtest "from stdin" => sub {
my( $output, $error );
t/uudecode/uudecode.t view on Meta::CPAN
SKIP: {
skip "Permissions make no sense on $^O", 1
if exists $SkipModePlatforms{$^O};
is(
sprintf( '%o', (stat $output_name)[2] & 0777 ),
$mode,
"output file has the right mode"
);
}
my $output = do { local( @ARGV, $/ ) = $output_name; <> };
close ARGV; # windows can't delete the file otherwise
is( $output, $decoded_text, "Output in <$output_name> is right" );
unlink $output_name or diag "Unintentionally leaving behind <$output_name>!: $!";
};
subtest 'decode_to_stdout' => sub {
my $output_name = '-';
my $mode = '664';
t/uudecode/uudecode.t view on Meta::CPAN
SKIP: {
skip "Permissions make no sense on $^O", 1
if exists $SkipModePlatforms{$^O};
is(
sprintf( '%o', (stat $alt_name)[2] & 0777 ),
$mode,
"output file has the right mode"
);
}
my $output = do { local( @ARGV, $/ ) = $alt_name; <> };
is( $output, $decoded_text, "standard output is the right message" );
unlink $alt_name or diag "Unintentionally leaving behind <$alt_name>! $!";
subtest 'decode_to_alt_stdout' => sub {
my $output = `"$^X" $program -o - $input_name`;
ok( ! -e $output_name, "output file <$output_name> is not there (good)" );
is( $output, $decoded_text, "standard output is the right message" );
};
};
( run in 1.424 second using v1.01-cache-2.11-cpan-49f99fa48dc )