diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-08-31 11:32:17 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-09-01 21:54:10 +0200 |
commit | a78a7b01301ef7aae3c0282c5fd1adcae3b1fbcd (patch) | |
tree | 1e5135698643e0059f5159427d379baa7b79a171 | |
parent | 0e9700df31679b575960004d0c9d53e4f67341b3 (diff) | |
download | perl-a78a7b01301ef7aae3c0282c5fd1adcae3b1fbcd.tar.gz |
In ext/POSIX/t/is.t, make better use of Test::More.
cmp_ok() will give better diagnostics than ok(). Using skip_all() is terser,
and will give better diagnostics.
-rw-r--r-- | ext/POSIX/t/is.t | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/ext/POSIX/t/is.t b/ext/POSIX/t/is.t index a0f5a45bd6..e029004b17 100644 --- a/ext/POSIX/t/is.t +++ b/ext/POSIX/t/is.t @@ -1,15 +1,16 @@ #!./perl -w +use strict; +use Test::More; +use Config; + BEGIN { - require Config; import Config; - if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) { - print "1..0\n"; - exit 0; - } + plan(skip_all => "\$^O eq '$^O'") if $^O eq 'VMS'; + plan(skip_all => "POSIX is unavailable") + unless $Config{extensions} =~ /\bPOSIX\b/; } use POSIX; -use strict ; # E.g. \t might or might not be isprint() depending on the locale, # so let's reset to the default. @@ -70,11 +71,8 @@ foreach my $s (keys %classes) { # Expected number of tests is one each for every combination of a # known is<xxx> function and string listed above. -use Test::More; plan(tests => keys(%classes) * keys(%functions)); - -# # Main test loop: Run all POSIX::is<xxx> tests on each string defined above. # Only the character classes listed for that string should return 1. We # always run all functions on every string, and expect to get 0 for the @@ -85,6 +83,6 @@ foreach my $s (sort keys %classes) { my $expected = exists $classes{$s}->{$f}; my $actual = eval "POSIX::$f( \$s )"; - ok( $actual == $expected, "$f('$s') == $actual"); + cmp_ok($actual, '==', $expected, "$f('$s')"); } } |