threads::shared tidy up:
[p5sagit/p5-mst-13.2.git] / ext / threads / shared / t / hv_refs.t
index cb38d99..9d9a47b 100644 (file)
@@ -29,7 +29,7 @@ use ExtUtils::testlib;
 use strict;
 BEGIN { print "1..17\n" };
 use threads;
-use threads::shared;
+use threads::shared qw(:DEFAULT _thrcnt _refcnt _id);
 ok(1,1,"loaded");
 my $foo;
 share($foo);
@@ -41,24 +41,26 @@ $foo = "test";
 ok(3, ${$foo{foo}} eq "test", "Check deref after assign");
 threads->create(sub{${$foo{foo}} = "test2";})->join();
 ok(4, $foo eq "test2", "Check after assign in another thread");
-skip(5, threads::shared::_thrcnt($foo) == 2, "Check refcount");
+skip(5, _thrcnt($foo) == 2, "Check refcount");
 my $bar = delete($foo{foo});
 ok(6, $$bar eq "test2", "check delete");
-skip(7, threads::shared::_thrcnt($foo) == 1, "Check refcount after delete");
+skip(7, _thrcnt($foo) == 1, "Check refcount after delete");
 threads->create( sub {
-my $test;
-share($test);
-$test = "thread3";
-$foo{test} = \$test;
-})->join();
+   my $test;
+   share($test);
+   $test = "thread3";
+   $foo{test} = \$test;
+   })->join();
 ok(8, ${$foo{test}} eq "thread3", "Check reference created in another thread");
 my $gg = $foo{test};
 $$gg = "test";
 ok(9, ${$foo{test}} eq "test", "Check reference");
-skip(10, threads::shared::_thrcnt($gg) == 2, "Check refcount");
+skip(10, _thrcnt($gg) == 2, "Check refcount");
 my $gg2 = delete($foo{test});
-skip(11, threads::shared::_thrcnt($gg) == 1, "Check refcount");
-ok(12, $gg == $gg2, "Check we get the same reference ($gg == $gg2)");
+skip(11, _thrcnt($gg) == 1, "Check refcount");
+ok(12, _id($gg) == _id($gg2),
+       sprintf("Check we get the same thing (%x vs %x)",
+       _id($$gg),_id($$gg2)));
 ok(13, $$gg eq $$gg2, "And check the values are the same");
 ok(14, keys %foo == 0, "And make sure we realy have deleted the values");
 {