diff options
Diffstat (limited to 'ext/Hash-Util-FieldHash/t/04_thread.t')
-rw-r--r-- | ext/Hash-Util-FieldHash/t/04_thread.t | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/ext/Hash-Util-FieldHash/t/04_thread.t b/ext/Hash-Util-FieldHash/t/04_thread.t index d9e6894496..fb85c052a0 100644 --- a/ext/Hash-Util-FieldHash/t/04_thread.t +++ b/ext/Hash-Util-FieldHash/t/04_thread.t @@ -1,29 +1,24 @@ -#!perl -use strict; use warnings; +use strict; +use warnings; use Test::More; -my $n_tests; +use Config; use Hash::Util::FieldHash qw( :all); + my $ob_reg = Hash::Util::FieldHash::_ob_reg; { - my $n_basic; - BEGIN { - $n_basic = 6; # 6 tests per call of basic_func() - $n_tests += 5*$n_basic; - } my %h; fieldhash %h; sub basic_func { my $level = shift; - my @res; my $push_is = sub { my ( $hash, $should, $name) = @_; push @res, [ scalar keys %$hash, $should, $name]; }; - + my $obj = []; $push_is->( \ %h, 0, "$level: initially clear"); $push_is->( $ob_reg, 0, "$level: ob_reg initially clear"); @@ -38,10 +33,9 @@ my $ob_reg = Hash::Util::FieldHash::_ob_reg; &is( @$_) for basic_func( "home"); - SKIP: { - require Config; - skip "No thread support", 3*$n_basic unless - $Config::Config{ usethreads}; + subtest 'threads' => sub { + plan skip_all => "No thread support" unless $Config{usethreads}; + require threads; my ( $t) = threads->create( \ &basic_func, "thread 1"); &is( @$_) for $t->join; @@ -53,10 +47,10 @@ my $ob_reg = Hash::Util::FieldHash::_ob_reg; $t->join; }); &is( @$_) for $t->join; - } + }; &is( @$_) for basic_func( "back home again"); } -BEGIN { plan tests => $n_tests } +done_testing(); |