2 use strict; use warnings;
6 use Hash::Util::FieldHash qw( :all);
7 my $ob_reg = Hash::Util::FieldHash::_ob_reg;
12 $n_basic = 6; # 6 tests per call of basic_func()
13 $n_tests += 5*$n_basic;
23 my ( $hash, $should, $name) = @_;
24 push @res, [ scalar keys %$hash, $should, $name];
28 $push_is->( \ %h, 0, "$level: initially clear");
29 $push_is->( $ob_reg, 0, "$level: ob_reg initially clear");
31 $push_is->( \ %h, 1, "$level: one object");
32 $push_is->( $ob_reg, 1, "$level: ob_reg one object");
34 $push_is->( \ %h, 0, "$level: garbage collected");
35 $push_is->( $ob_reg, 0, "$level: ob_reg garbage collected");
39 &is( @$_) for basic_func( "home");
43 skip "No thread support", 3*$n_basic unless
44 $Config::Config{ usethreads};
46 my ( $t) = threads->create( \ &basic_func, "thread 1");
47 &is( @$_) for $t->join;
49 &is( @$_) for basic_func( "back home");
51 ( $t) = threads->create( sub {
52 my ( $t) = threads->create( \ &basic_func, "thread 2");
55 &is( @$_) for $t->join;
58 &is( @$_) for basic_func( "back home again");
62 BEGIN { plan tests => $n_tests }