5 if ($ENV{'PERL_CORE'}){
7 unshift @INC, '../lib';
10 if (! $Config{'useithreads'}) {
11 print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
16 use ExtUtils::testlib;
19 my ($id, $ok, $name) = @_;
21 # You have to do it this way or VMS will get confused.
23 print("ok $id - $name\n");
25 print("not ok $id - $name\n");
26 printf("# Failed test at line %d\n", (caller)[2]);
34 print("1..16\n"); ### Number of tests that will be run ###
41 ### Start of Testing ###
46 ok(2,$hash{"foo"} eq "bar","Check hash get");
47 threads->create(sub { $hash{"bar"} = "thread1"})->join();
48 threads->create(sub { ok(3,$hash{"bar"} eq "thread1", "Check thread get and write")})->join();
50 my $foo = delete($hash{"bar"});
51 ok(4, $foo eq "thread1", "Check delete, want 'thread1' got '$foo'");
52 $foo = delete($hash{"bar"});
53 ok(5, !defined $foo, "Check delete on empty value");
55 ok(6, keys %hash == 1, "Check keys");
59 ok(7, keys %hash == 4, "Check keys");
60 ok(8, exists($hash{"1"}), "Exist on existing key");
61 ok(9, !exists($hash{"4"}), "Exists on non existing key");
63 foreach my $key ( keys %hash) {
66 ok(10, $seen{1} == 1, "Keys..");
67 ok(11, $seen{2} == 1, "Keys..");
68 ok(12, $seen{3} == 1, "Keys..");
69 ok(13, $seen{"foo"} == 1, "Keys..");
71 # bugid #24407: the stringification of the numeric 1 got allocated to the
72 # wrong thread memory pool, which crashes on Windows.
73 ok(14, exists $hash{1}, "Check numeric key");
75 threads->create(sub { %hash = () })->join();
76 ok(15, keys %hash == 0, "Check clear");
78 ok(16, is_shared(%hash), "Check for sharing");