mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 16:39:36 +00:00
Tidy lib/Getopt/Std.t
Replace internal hard-tabs used for alignment of test descriptions.
This commit is contained in:
parent
dbd5de70cc
commit
778ca25b31
@ -17,41 +17,41 @@ our ($warning, $opt_f, $opt_i, $opt_o, $opt_x, $opt_y, %opt);
|
||||
@ARGV = qw(-xo -f foo -y file);
|
||||
getopt('f');
|
||||
|
||||
is( "@ARGV", 'file', 'options removed from @ARGV (1)' );
|
||||
is( "@ARGV", 'file', 'options removed from @ARGV (1)' );
|
||||
ok( $opt_x && $opt_o && $opt_y, 'options -x, -o and -y set' );
|
||||
is( $opt_f, 'foo', q/option -f is 'foo'/ );
|
||||
is( $opt_f, 'foo', q/option -f is 'foo'/ );
|
||||
|
||||
@ARGV = qw(-hij k -- -l m -n);
|
||||
getopt 'il', \%opt;
|
||||
|
||||
is( "@ARGV", 'k -- -l m -n', 'options removed from @ARGV (2)' );
|
||||
ok( $opt{h} && $opt{i} eq 'j', 'option -h and -i correctly set' );
|
||||
ok( !defined $opt{l}, 'option -l not set' );
|
||||
ok( !defined $opt_i, '$opt_i still undefined' );
|
||||
is( "@ARGV", 'k -- -l m -n', 'options removed from @ARGV (2)' );
|
||||
ok( $opt{h} && $opt{i} eq 'j', 'option -h and -i correctly set' );
|
||||
ok( !defined $opt{l}, 'option -l not set' );
|
||||
ok( !defined $opt_i, '$opt_i still undefined' );
|
||||
|
||||
# Then we try the getopts
|
||||
$opt_o = $opt_i = $opt_f = undef;
|
||||
@ARGV = qw(-foi -i file);
|
||||
|
||||
ok( getopts('oif:'), 'getopts succeeded (1)' );
|
||||
is( "@ARGV", 'file', 'options removed from @ARGV (3)' );
|
||||
ok( $opt_i && $opt_f eq 'oi', 'options -i and -f correctly set' );
|
||||
ok( !defined $opt_o, 'option -o not set' );
|
||||
ok( getopts('oif:'), 'getopts succeeded (1)' );
|
||||
is( "@ARGV", 'file', 'options removed from @ARGV (3)' );
|
||||
ok( $opt_i && $opt_f eq 'oi', 'options -i and -f correctly set' );
|
||||
ok( !defined $opt_o, 'option -o not set' );
|
||||
|
||||
%opt = (); $opt_i = undef;
|
||||
@ARGV = qw(-hij -k -- -l m);
|
||||
|
||||
ok( getopts('hi:kl', \%opt), 'getopts succeeded (2)' );
|
||||
is( "@ARGV", '-l m', 'options removed from @ARGV (4)' );
|
||||
ok( $opt{h} && $opt{k}, 'options -h and -k set' );
|
||||
is( $opt{i}, 'j', q/option -i is 'j'/ );
|
||||
ok( !defined $opt_i, '$opt_i still undefined' );
|
||||
ok( getopts('hi:kl', \%opt), 'getopts succeeded (2)' );
|
||||
is( "@ARGV", '-l m', 'options removed from @ARGV (4)' );
|
||||
ok( $opt{h} && $opt{k}, 'options -h and -k set' );
|
||||
is( $opt{i}, 'j', q/option -i is 'j'/ );
|
||||
ok( !defined $opt_i, '$opt_i still undefined' );
|
||||
|
||||
# Try illegal options, but avoid printing of the error message
|
||||
$SIG{__WARN__} = sub { $warning = $_[0] };
|
||||
@ARGV = qw(-h help);
|
||||
|
||||
ok( !getopts("xf:y"), 'getopts fails for an illegal option' );
|
||||
ok( !getopts("xf:y"), 'getopts fails for an illegal option' );
|
||||
ok( $warning eq "Unknown option: h\n", 'user warned' );
|
||||
|
||||
# Tests for RT #41359
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user