6 require Config; import Config;
7 unless ($Config{'useithreads'}) {
8 print "1..0 # Skip: no useithreads\n";
15 my ($id, $ok, $name) = @_;
17 $name = '' unless defined $name;
18 # You have to do it this way or VMS will get confused.
19 print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
21 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
27 my ($id, $ok, $name) = @_;
28 print "ok $id # skip _thrcnt - $name \n";
33 use ExtUtils::testlib;
35 BEGIN { print "1..15\n" };
42 ok(2,$hash{"foo"} eq "bar","Check hash get");
43 threads->create(sub { $hash{"bar"} = "thread1"})->join();
44 threads->create(sub { ok(3,$hash{"bar"} eq "thread1", "Check thread get and write")})->join();
46 my $foo = delete($hash{"bar"});
47 ok(4, $foo eq "thread1", "Check delete, want 'thread1' got '$foo'");
48 $foo = delete($hash{"bar"});
49 ok(5, !defined $foo, "Check delete on empty value");
51 ok(6, keys %hash == 1, "Check keys");
55 ok(7, keys %hash == 4, "Check keys");
56 ok(8, exists($hash{"1"}), "Exist on existing key");
57 ok(9, !exists($hash{"4"}), "Exists on non existing key");
59 foreach my $key ( keys %hash) {
62 ok(10, $seen{1} == 1, "Keys..");
63 ok(11, $seen{2} == 1, "Keys..");
64 ok(12, $seen{3} == 1, "Keys..");
65 ok(13, $seen{"foo"} == 1, "Keys..");
67 # bugid #24407: the stringification of the numeric 1 got allocated to the
68 # wrong thread memory pool, which crashes on Windows.
69 ok(14, exists $hash{1}, "Check numeric key");
71 threads->create(sub { %hash = () })->join();
72 ok(15, keys %hash == 0, "Check clear");