|
9 | 9 | use strict;
|
10 | 10 | use File::Spec;
|
11 | 11 | use POSIX;
|
12 |
| -use Scalar::Util qw(looks_like_number); |
13 | 12 |
|
14 | 13 | sub check(@) {
|
15 | 14 | grep { eval "&$_;1" or $@!~/vendor has not defined POSIX macro/ } @_
|
@@ -57,21 +56,19 @@ sub _check_and_report {
|
57 | 56 | my ($sub, $constant, $description) = @_;
|
58 | 57 | $! = 0;
|
59 | 58 | my $return_val = eval {$sub->(eval "$constant()")};
|
60 |
| - my $success = defined($return_val) || $! == 0; |
| 59 | + my $errno = $!; # Grab this before anything else changes it. |
61 | 60 | is($@, '', $description);
|
62 | 61 | SKIP: {
|
63 | 62 | skip "terminal constants set errno on QNX", 1
|
64 | 63 | if $^O eq 'nto' and $description =~ $TTY;
|
65 |
| - ok( $success, "\tchecking that the returned value is defined (" |
66 |
| - . (defined($return_val) ? "yes, it's $return_val)" : "it isn't)" |
67 |
| - . " or that errno is clear (" |
68 |
| - . (!($!+0) ? "it is)" : "it isn't, it's $!)")) |
69 |
| - ); |
| 64 | + cmp_ok($errno, '==', 0, 'errno should be clear in all cases') |
| 65 | + or diag("\$!: $errno"); |
70 | 66 | }
|
71 | 67 | SKIP: {
|
72 | 68 | skip "constant not implemented on $^O or no limit in effect", 1
|
73 | 69 | if !defined($return_val);
|
74 |
| - ok( looks_like_number($return_val), "\tchecking that the returned value looks like a number" ); |
| 70 | + like($return_val, qr/\A(?:-?[1-9][0-9]*|0 but true)\z/, |
| 71 | + 'the returned value should be a signed integer'); |
75 | 72 | }
|
76 | 73 | }
|
77 | 74 |
|
|
0 commit comments