my $TTY = "/dev/tty";
sub _check_and_report {
- my ($eval_status, $return_val, $description) = @_;
+ my ($sub, $constant, $description) = @_;
+ $! = 0;
+ my $return_val = eval {$sub->(eval "$constant()")};
my $success = defined($return_val) || $! == 0;
- is( $eval_status, '', $description );
+ is($@, '', $description);
SKIP: {
skip "terminal constants set errno on QNX", 1
if $^O eq 'nto' and $description =~ $TTY;
3 * @path_consts;
for my $constant (@path_consts) {
- $! = 0;
- $r = eval { fpathconf( $fd, eval "$constant()" ) };
- _check_and_report( $@, $r, "calling fpathconf($fd, $constant) " );
+ _check_and_report(sub { fpathconf($fd, shift) }, $constant,
+ "calling fpathconf($fd, $constant)");
}
POSIX::close($fd);
# testing pathconf() on a non-terminal file
for my $constant (@path_consts) {
- $! = 0;
- $r = eval { pathconf( $testdir, eval "$constant()" ) };
- _check_and_report( $@, $r, qq[calling pathconf("$testdir", $constant)] );
+ _check_and_report(sub { pathconf($testdir, shift) }, $constant,
+ "calling pathconf('$testdir', $constant)");
}
SKIP: {
# testing fpathconf() on a terminal file
for my $constant (@path_consts_terminal) {
- $! = 0;
- $r = eval { fpathconf( $fd, eval "$constant()" ) };
- _check_and_report( $@, $r, qq[calling fpathconf($fd, $constant) ($TTY)] );
+ _check_and_report(sub { fpathconf($fd, shift) }, $constant,
+ "calling fpathconf($fd, $constant) ($TTY)");
}
close($fd);
# testing pathconf() on a terminal file
for my $constant (@path_consts_terminal) {
- $! = 0;
- $r = eval { pathconf( $TTY, eval "$constant()" ) };
- _check_and_report( $@, $r, qq[calling pathconf($TTY, $constant)] );
+ _check_and_report(sub { pathconf($TTY, shift) }, $constant,
+ "calling pathconf($TTY, $constant)");
}
}
or skip("could not open $fifo ($!)", 3 * @path_consts_fifo);
for my $constant (@path_consts_fifo) {
- $! = 0;
- $r = eval { fpathconf( $fd, eval "$constant()" ) };
- _check_and_report( $@, $r, "calling fpathconf($fd, $constant) ($fifo)" );
+ _check_and_report(sub { fpathconf($fd, shift) }, $constant,
+ "calling fpathconf($fd, $constant) ($fifo)");
}
POSIX::close($fd);
# testing pathconf() on a fifo file
for my $constant (@path_consts_fifo) {
- $! = 0;
- $r = eval { pathconf( $fifo, eval "$constant()" ) };
- _check_and_report( $@, $r, qq[calling pathconf($fifo, $constant)] );
+ _check_and_report(sub { pathconf($fifo, shift) }, $constant,
+ "calling pathconf($fifo, $constant");
}
}
}
# testing sysconf()
for my $constant (@sys_consts) {
- $! = 0;
- $r = eval { sysconf( eval "$constant()" ) };
- _check_and_report( $@, $r, "calling sysconf($constant)" );
+ _check_and_report(sub {sysconf(shift)}, $constant,
+ "calling sysconf($constant)");
}
-