From: Jerry D. Hedden Date: Wed, 30 Jan 2008 09:15:25 +0000 (-0500) Subject: threads::shared TODO test for outstanding bug X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ea6a7c5888642f2a40f4c7124bc00d68d8d40278;p=p5sagit%2Fp5-mst-13.2.git threads::shared TODO test for outstanding bug From: "Jerry D. Hedden" Message-ID: <1ff86f510801300615t1f9e8c68u5ff8caaeffb1a835@mail.gmail.com> p4raw-id: //depot/perl@33154 --- diff --git a/ext/threads/shared/t/object.t b/ext/threads/shared/t/object.t index d244a31..5c5a55e 100644 --- a/ext/threads/shared/t/object.t +++ b/ext/threads/shared/t/object.t @@ -21,7 +21,7 @@ use ExtUtils::testlib; BEGIN { $| = 1; - print("1..23\n"); ### Number of tests that will be run ### + print("1..28\n"); ### Number of tests that will be run ### }; use threads; @@ -148,4 +148,34 @@ ok($jar->peek()->{'type'} eq $C3, 'Still have cookie in jar'); $cookie = $jar->fetch(); ok($cookie->{'type'} eq $C3, 'Fetched cookie from jar'); +{ package Foo; + + my $ID = 1; + threads::shared::share($ID); + + sub new + { + # Anonymous scalar with an internal ID + my $obj = \do{ my $scalar = $ID++; }; + threads::shared::share($obj); # Make it shared + return (bless($obj, 'Foo')); # Make it an object + } +} + +my $obj :shared; +$obj = Foo->new(); +ok($$obj == 1, "Main: Object ID $$obj"); + +threads->create( sub { + ok($$obj == 1, "Thread: Object ID $$obj"); + + $$obj = 10; + ok($$obj == 10, "Thread: Changed object ID $$obj"); + + $obj = Foo->new(); + ok($$obj == 2, "Thread: New object ID $$obj"); + } )->join(); + +ok($$obj == 2, "Main: New object ID $$obj # TODO - should be 2"); + # EOF