In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/273be65c18c94ccde36c8a6d14c992ff7434681a?hp=0758e0bfd6d4d39eeabc9f405c9c8dd727335f80>
- Log ----------------------------------------------------------------- commit 273be65c18c94ccde36c8a6d14c992ff7434681a Author: Nicholas Clark <[email protected]> Date: Sat Mar 12 17:44:59 2011 +0000 Rename test.pl's skip_all_without_extension to *_dynamic_extension(). All callers were using it with dynamic extensions, and also had a skip_all_if_miniperl() for the same extension. Merge the two tests into one function to save repetition. M t/io/layers.t M t/io/perlio_open.t M t/lib/proxy_constant_subs.t M t/test.pl M t/uni/chomp.t M t/uni/chr.t M t/uni/greek.t M t/uni/latin2.t M t/uni/tr_7jis.t M t/uni/tr_eucjp.t M t/uni/tr_sjis.t M t/uni/tr_utf8.t commit 63dddcfa05d3d59b8fec7157e6f887bae33b68e6 Author: Nicholas Clark <[email protected]> Date: Sat Mar 12 17:22:44 2011 +0000 Convert t/op/readdir.t to test.pl, strict and warnings. M t/op/readdir.t ----------------------------------------------------------------------- Summary of changes: t/io/layers.t | 3 +- t/io/perlio_open.t | 3 +- t/lib/proxy_constant_subs.t | 3 +- t/op/readdir.t | 63 +++++++++++++++++++++++------------------- t/test.pl | 3 +- t/uni/chomp.t | 3 +- t/uni/chr.t | 3 +- t/uni/greek.t | 3 +- t/uni/latin2.t | 3 +- t/uni/tr_7jis.t | 3 +- t/uni/tr_eucjp.t | 3 +- t/uni/tr_sjis.t | 3 +- t/uni/tr_utf8.t | 3 +- 13 files changed, 47 insertions(+), 52 deletions(-) diff --git a/t/io/layers.t b/t/io/layers.t index d0b55f1..55dc2fa 100644 --- a/t/io/layers.t +++ b/t/io/layers.t @@ -8,8 +8,7 @@ BEGIN { require './test.pl'; skip_all_without_perlio(); # FIXME - more of these could be tested without Encode or full perl - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); - skip_all_without_extension('Encode'); + skip_all_without_dynamic_extension('Encode'); # Makes testing easier. $ENV{PERLIO} = 'stdio' if exists $ENV{PERLIO} && $ENV{PERLIO} eq ''; diff --git a/t/io/perlio_open.t b/t/io/perlio_open.t index 9969796..702c76c 100644 --- a/t/io/perlio_open.t +++ b/t/io/perlio_open.t @@ -5,8 +5,7 @@ BEGIN { @INC = '../lib'; require './test.pl'; skip_all_without_perlio(); - skip_all_if_miniperl("no dynamic loading on miniperl, no Fcntl"); - skip_all_without_extension('Fcntl'); # how did you get this far? + skip_all_without_dynamic_extension('Fcntl'); # how did you get this far? } use strict; diff --git a/t/lib/proxy_constant_subs.t b/t/lib/proxy_constant_subs.t index c6de618..e3cb41d 100644 --- a/t/lib/proxy_constant_subs.t +++ b/t/lib/proxy_constant_subs.t @@ -1,8 +1,7 @@ my @symbols; BEGIN { require './test.pl'; - skip_all_without_extension('B'); - skip_all_without_extension('Fcntl'); + skip_all_without_dynamic_extension($_) foreach qw(B Fcntl); # S_IFMT is a real subroutine, and acts as control # SEEK_SET is a proxy constant subroutine. @symbols = qw(S_IFMT SEEK_SET); diff --git a/t/op/readdir.t b/t/op/readdir.t index 8bf5610..e642d86 100644 --- a/t/op/readdir.t +++ b/t/op/readdir.t @@ -3,37 +3,39 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; + require './test.pl'; } -eval 'opendir(NOSUCH, "no/such/directory");'; -if ($@) { print "1..0\n"; exit; } +use strict; +use warnings; +use vars qw($fh @fh %fh); -print "1..12\n"; +eval 'opendir(NOSUCH, "no/such/directory");'; +skip_all($@) if $@; -for $i (1..2000) { +for my $i (1..2000) { local *OP; opendir(OP, "op") or die "can't opendir: $!"; # should auto-closedir() here } -if (opendir(OP, "op")) { print "ok 1\n"; } else { print "not ok 1\n"; } -@D = grep(/^[^\.].*\.t$/i, readdir(OP)); +is(opendir(OP, "op"), 1); +my @D = grep(/^[^\.].*\.t$/i, readdir(OP)); closedir(OP); -open $man, "<../MANIFEST" or die "Can't open ../MANIFEST: $!"; my $expect; -while (<$man>) { - ++$expect if m!^t/op/[^/]+\t!; +{ + open my $man, '<', '../MANIFEST' or die "Can't open ../MANIFEST: $!"; + while (<$man>) { + ++$expect if m!^t/op/[^/]+\t!; + } } + my ($min, $max) = ($expect - 10, $expect + 10); -if (@D > $min && @D < $max) { print "ok 2\n"; } -else { - printf "not ok 2 # counting op/*.t, expect $min < %d < $max files\n", - scalar @D; -} +within(scalar @D, $expect, 10, 'counting op/*.t'); -@R = sort @D; -@G = sort <op/*.t>; +my @R = sort @D; +my @G = sort <op/*.t>; if ($G[0] =~ m#.*\](\w+\.t)#i) { # grep is to convert filespecs returned from glob under VMS to format # identical to that returned by readdir @@ -43,20 +45,23 @@ while (@R && @G && $G[0] eq 'op/'.$R[0]) { shift(@R); shift(@G); } -if (@R == 0 && @G == 0) { print "ok 3\n"; } else { print "not ok 3\n"; } - -if (opendir($fh, "op")) { print "ok 4\n"; } else { print "not ok 4\n"; } -if (ref($fh) eq 'GLOB') { print "ok 5\n"; } else { print "not ok 5\n"; } -if (opendir($fh[0], "op")) { print "ok 6\n"; } else { print "not ok 6\n"; } -if (ref($fh[0]) eq 'GLOB') { print "ok 7\n"; } else { print "not ok 7\n"; } -if (opendir($fh{abc}, "op")) { print "ok 8\n"; } else { print "not ok 8\n"; } -if (ref($fh{abc}) eq 'GLOB') { print "ok 9\n"; } else { print "not ok 9\n"; } -if ("$fh" ne "$fh[0]") { print "ok 10\n"; } else { print "not ok 10\n"; } -if ("$fh" ne "$fh{abc}") { print "ok 11\n"; } else { print "not ok 11\n"; } +is(scalar @R, 0, 'readdir results all accounted for'); +is(scalar @G, 0, 'glob results all accounted for'); + +is(opendir($fh, "op"), 1); +is(ref $fh, 'GLOB'); +is(opendir($fh[0], "op"), 1); +is(ref $fh[0], 'GLOB'); +is(opendir($fh{abc}, "op"), 1); +is(ref $fh{abc}, 'GLOB'); +isnt("$fh", "$fh[0]"); +isnt("$fh", "$fh{abc}"); + # See that perl does not segfault upon readdir($x="."); # http://rt.perl.org/rt3/Ticket/Display.html?id=68182 -eval { +fresh_perl_like(<<'EOP', qr/^Bad symbol for dirhandle at -/, {}, 'RT #68182'); my $x = "."; my @files = readdir($x); -}; -print "ok 12\n"; +EOP + +done_testing(); diff --git a/t/test.pl b/t/test.pl index 34150aa..21bf1d2 100644 --- a/t/test.pl +++ b/t/test.pl @@ -122,8 +122,9 @@ sub skip_all_if_miniperl { skip_all(@_) if is_miniperl(); } -sub skip_all_without_extension { +sub skip_all_without_dynamic_extension { my $extension = shift; + skip_all("no dynamic loading on miniperl, no $extension") if is_miniperl(); unless (eval {require Config; 1}) { warn "test.pl had problems loading Config: $@"; return; diff --git a/t/uni/chomp.t b/t/uni/chomp.t index 1292fb6..0dca91a 100644 --- a/t/uni/chomp.t +++ b/t/uni/chomp.t @@ -2,10 +2,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } use strict; diff --git a/t/uni/chr.t b/t/uni/chr.t index 227dc52..33283e7 100644 --- a/t/uni/chr.t +++ b/t/uni/chr.t @@ -2,10 +2,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } use strict; diff --git a/t/uni/greek.t b/t/uni/greek.t index a1ca3c4..1737a67 100644 --- a/t/uni/greek.t +++ b/t/uni/greek.t @@ -2,10 +2,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } plan tests => 72; diff --git a/t/uni/latin2.t b/t/uni/latin2.t index 344d1a8..1527471 100644 --- a/t/uni/latin2.t +++ b/t/uni/latin2.t @@ -2,10 +2,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } plan tests => 94; diff --git a/t/uni/tr_7jis.t b/t/uni/tr_7jis.t index 90f3431..2118070 100644 --- a/t/uni/tr_7jis.t +++ b/t/uni/tr_7jis.t @@ -6,10 +6,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } use strict; diff --git a/t/uni/tr_eucjp.t b/t/uni/tr_eucjp.t index 352684d..27daf32 100644 --- a/t/uni/tr_eucjp.t +++ b/t/uni/tr_eucjp.t @@ -5,10 +5,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } use strict; diff --git a/t/uni/tr_sjis.t b/t/uni/tr_sjis.t index fca9d6c..290dd8c 100644 --- a/t/uni/tr_sjis.t +++ b/t/uni/tr_sjis.t @@ -5,10 +5,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } use strict; diff --git a/t/uni/tr_utf8.t b/t/uni/tr_utf8.t index aa8f439..25a6753 100644 --- a/t/uni/tr_utf8.t +++ b/t/uni/tr_utf8.t @@ -6,10 +6,9 @@ BEGIN { require './test.pl'; - skip_all_if_miniperl("no dynamic loading on miniperl, no Encode"); + skip_all_without_dynamic_extension('Encode'); skip_all("EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); - skip_all_without_extension('Encode'); } use strict; -- Perl5 Master Repository
