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;
$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