This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
64c2529a71e3b0eea6387786a4066fa1b2317f34
[perl5.git] / cpan / Digest-MD5 / t / threads.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use Config;
5
6 BEGIN {
7     plan skip_all => 'Perl compiled without ithreads'
8         unless $Config{useithreads};
9     plan skip_all => 'no threads.pm'
10         unless eval { require threads };
11     plan tests => 2;
12 }
13
14 use threads;
15 use Digest::MD5;
16
17 my $module = 'Digest::MD5';
18
19 my $obj = $module->new;
20 $obj->add("foo");
21 my $tdigest = threads->create(sub { $obj->add("bar"); $obj->hexdigest })->join;
22
23 isnt $obj->clone->hexdigest, $tdigest, "unshared object unaffected by the thread";
24
25 $obj->add("bar");
26 is $obj->clone->hexdigest, $tdigest;