Blame t/threads.t

Packit fc16e3
use strict;
Packit fc16e3
use warnings;
Packit fc16e3
use Test::More;
Packit fc16e3
use Config;
Packit fc16e3
Packit fc16e3
BEGIN {
Packit fc16e3
    plan skip_all => 'Perl not compiled with useithreads'
Packit fc16e3
        if !$Config{useithreads};
Packit fc16e3
    plan skip_all => 'This test does not cope well with this version of perl'
Packit fc16e3
        if "$]" == 5.008_002
Packit fc16e3
        or ("$]" < 5.013_004 and not $ENV{AUTHOR_TESTING});
Packit fc16e3
    plan tests => 4;
Packit fc16e3
}
Packit fc16e3
Packit fc16e3
use threads;
Packit fc16e3
use Data::UUID;
Packit fc16e3
Packit fc16e3
my $ug = Data::UUID->new;
Packit fc16e3
Packit fc16e3
my @threads = map {
Packit fc16e3
    threads->create(sub { ($ug->create_str, Data::UUID->new->create_str) });
Packit fc16e3
} 1 .. 20;
Packit fc16e3
Packit fc16e3
my @ret = map {
Packit fc16e3
    $_->join
Packit fc16e3
} @threads;
Packit fc16e3
Packit fc16e3
pass 'we survived our threads';
Packit fc16e3
Packit fc16e3
is @ret, 40, 'got as all the uuids we expected';
Packit fc16e3
ok !grep({ !defined } @ret), 'uuids look sane';
Packit fc16e3
Packit fc16e3
my %uuids = map { $_ => 1 } @ret;
Packit fc16e3
is keys %uuids, @ret, "all UUIDs are unique";