xref: /openbsd-src/gnu/usr.bin/perl/cpan/Digest-MD5/t/threads.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1use strict;
2use warnings;
3use Test::More;
4use Config;
5
6BEGIN {
7    plan skip_all => 'Perl compiled without ithreads'
8        unless $Config{useithreads};
9    plan tests => 2;
10}
11
12use threads;
13use Digest::MD5;
14
15my $module = 'Digest::MD5';
16
17my $obj = $module->new;
18$obj->add("foo");
19my $tdigest = threads->create(sub { $obj->add("bar"); $obj->hexdigest })->join;
20
21isnt $obj->clone->hexdigest, $tdigest, "unshared object unaffected by the thread";
22
23$obj->add("bar");
24is $obj->clone->hexdigest, $tdigest;
25