+use strict;
use warnings;
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;
+ if ($ENV{'PERL_CORE'}){
+ chdir 't';
+ unshift @INC, '../lib';
+ }
+ use Config;
+ if (! $Config{'useithreads'}) {
+ print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
+ exit(0);
}
}
+use ExtUtils::testlib;
sub ok {
my ($id, $ok, $name) = @_;
- $name = '' unless defined $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;
+ if ($ok) {
+ print("ok $id - $name\n");
+ } else {
+ print("not ok $id - $name\n");
+ printf("# Failed test at line %d\n", (caller)[2]);
+ }
- return $ok;
+ return ($ok);
}
+BEGIN {
+ $| = 1;
+ print("1..44\n"); ### Number of tests that will be run ###
+};
-
-use ExtUtils::testlib;
-use strict;
-BEGIN { print "1..43\n" };
use threads;
use threads::shared;
-ok(1,1,"loaded");
+ok(1, 1, 'Loaded');
+
+### Start of Testing ###
+
my @foo;
share(@foo);
ok(2,1,"shared \@foo");
}
{
eval {
- my @t1 = splice(@foo,0,2,"hop", "hej");
+ my @t1 = splice(@foo,0,2,"hop", "hej");
};
ok(43, my $temp1 = $@ =~/Splice not implemented for shared arrays/, "Check that the warning message is correct for non splice");
}
+
+ok(44, is_shared(@foo), "Check for sharing");
+
+exit(0);
+
+# EOF