diff options
author | Artur Bergman <sky@nanisky.com> | 2001-10-26 08:30:11 +0000 |
---|---|---|
committer | Artur Bergman <sky@nanisky.com> | 2001-10-26 08:30:11 +0000 |
commit | 0dc5f2bb966f13a2958959b7f7d94400bd67c466 (patch) | |
tree | cdb6e1258e3f91b825cb94b5b893e521afb10387 /ext | |
parent | 36f8622d5971e275a7102b12d1acf96b8bd5bc28 (diff) | |
download | perl-0dc5f2bb966f13a2958959b7f7d94400bd67c466.tar.gz |
Add tests for references in hashes.
p4raw-id: //depot/perl@12670
Diffstat (limited to 'ext')
-rw-r--r-- | ext/threads/shared/t/hv_refs.t | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ext/threads/shared/t/hv_refs.t b/ext/threads/shared/t/hv_refs.t new file mode 100644 index 0000000000..53029bfcd5 --- /dev/null +++ b/ext/threads/shared/t/hv_refs.t @@ -0,0 +1,44 @@ +BEGIN { +# chdir 't' if -d 't'; +# push @INC ,'../lib'; + require Config; import Config; + unless ($Config{'useithreads'}) { + print "1..0 # Skip: no useithreads\n"; + exit 0; + } +} + + +sub ok { + my ($id, $ok, $name) = @_; + + # You have to do it this way or VMS will get confused. + print $ok ? "ok $id - $name\n" : "not ok $id - $name\n"; + + printf "# Failed test at line %d\n", (caller)[2] unless $ok; + + return $ok; +} + + + +use ExtUtils::testlib; +use strict; +BEGIN { print "1..7\n" }; +use threads; +use threads::shared; +ok(1,1,"loaded"); +my $foo; +share($foo); +my %foo; +share(%foo); +$foo{"foo"} = \$foo; +ok(2, ${$foo{foo}} == undef, "Check deref"); +$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"); +ok(5, threads::shared::_thrcnt($foo) == 2, "Check refcount"); +my $bar = delete($foo{foo}); +ok(6, $$bar eq "test2", "check delete"); +ok(7, threads::shared::_thrcnt($foo) == 1, "Check refcount after delete"); |