Change 33154 by [EMAIL PROTECTED] on 2008/01/31 17:08:22

        Subject: [PATCH] threads::shared TODO test for outstanding bug
        From: "Jerry D. Hedden" <[EMAIL PROTECTED]>
        Date: Wed, 30 Jan 2008 09:15:25 -0500
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/ext/threads/shared/t/object.t#2 edit

Differences ...

==== //depot/perl/ext/threads/shared/t/object.t#2 (text) ====
Index: perl/ext/threads/shared/t/object.t
--- perl/ext/threads/shared/t/object.t#1~32658~ 2007-12-19 09:17:45.000000000 
-0800
+++ perl/ext/threads/shared/t/object.t  2008-01-31 09:08:22.000000000 -0800
@@ -21,7 +21,7 @@
 
 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 @@
 $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
End of Patch.

Reply via email to