test suite and fix input_line_number()
[p5sagit/p5-mst-13.2.git] / t / lib / thread.t
index fecfb03..5cc2eaf 100755 (executable)
@@ -2,16 +2,18 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = '../lib';
+    unshift @INC, '../lib';
     require Config; import Config;
     if (! $Config{'usethreads'}) {
        print "1..0\n";
        exit 0;
     }
-    $ENV{PERL_DESTRUCT_LEVEL} = 0;     # XXX known trouble with global destruction
+
+    # XXX known trouble with global destruction
+    $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
 }
 $| = 1;
-print "1..14\n";
+print "1..18\n";
 use Thread;
 print "ok 1\n";
 
@@ -22,7 +24,7 @@ sub content
 }
 
 # create a thread passing args and immedaietly wait for it.
-my $t = new Thread \&content,("ok 2\n","ok 3\n");
+my $t = new Thread \&content,("ok 2\n","ok 3\n", 1..1000);
 print $t->join;
 
 # check that lock works ...
@@ -69,3 +71,17 @@ sub islocked
 $t = Thread->new(\&islocked, "ok 13\n", "ok 14\n");
 $t->join->join;
 
+{
+    package Loch::Ness;
+    sub new { bless [], shift }
+    sub monster {
+       use attrs qw(locked method);
+       my($s, $m) = @_;
+       print "ok $m\n";
+    }
+    sub gollum { &monster }
+}
+Loch::Ness->monster(15);
+Loch::Ness->new->monster(16);
+Loch::Ness->gollum(17);
+Loch::Ness->new->gollum(18);