summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-09-09 18:59:00 +0200
committerNicholas Clark <nick@ccl4.org>2011-09-13 11:28:09 +0200
commit6d7cccf9e0c72e7b830e1d803758ce556659bd8f (patch)
treeda5bca1e2ea33a8335267991b6947b6e1f688ee0
parent7187b54eeb7e64af33ff527e35951639b832b257 (diff)
downloadperl-6d7cccf9e0c72e7b830e1d803758ce556659bd8f.tar.gz
In ext/POSIX/t/sysconf.t, make the tests more strict.
$! should always be 0 after each call, so test this whether the result is defined or undefined. Match a defined result against a regex to ensure that it is an integer, and give better diagnostics if it is not.
-rw-r--r--ext/POSIX/t/sysconf.t13
1 files changed, 5 insertions, 8 deletions
diff --git a/ext/POSIX/t/sysconf.t b/ext/POSIX/t/sysconf.t
index 910b15a35d..8008996b63 100644
--- a/ext/POSIX/t/sysconf.t
+++ b/ext/POSIX/t/sysconf.t
@@ -9,7 +9,6 @@ BEGIN {
use strict;
use File::Spec;
use POSIX;
-use Scalar::Util qw(looks_like_number);
sub check(@) {
grep { eval "&$_;1" or $@!~/vendor has not defined POSIX macro/ } @_
@@ -57,21 +56,19 @@ sub _check_and_report {
my ($sub, $constant, $description) = @_;
$! = 0;
my $return_val = eval {$sub->(eval "$constant()")};
- my $success = defined($return_val) || $! == 0;
+ my $errno = $!; # Grab this before anything else changes it.
is($@, '', $description);
SKIP: {
skip "terminal constants set errno on QNX", 1
if $^O eq 'nto' and $description =~ $TTY;
- ok( $success, "\tchecking that the returned value is defined ("
- . (defined($return_val) ? "yes, it's $return_val)" : "it isn't)"
- . " or that errno is clear ("
- . (!($!+0) ? "it is)" : "it isn't, it's $!)"))
- );
+ cmp_ok($errno, '==', 0, 'errno should be clear in all cases')
+ or diag("\$!: $errno");
}
SKIP: {
skip "constant not implemented on $^O or no limit in effect", 1
if !defined($return_val);
- ok( looks_like_number($return_val), "\tchecking that the returned value looks like a number" );
+ like($return_val, qr/\A(?:-?[1-9][0-9]*|0 but true)\z/,
+ 'the returned value should be a signed integer');
}
}