Commit | Line | Data |
---|---|---|
62d37bf0 FR |
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 tests => 2; | |
10 | } | |
11 | ||
12 | use threads; | |
13 | use Digest::MD5; | |
14 | ||
15 | my $module = 'Digest::MD5'; | |
16 | ||
17 | my $obj = $module->new; | |
18 | $obj->add("foo"); | |
19 | my $tdigest = threads->create(sub { $obj->add("bar"); $obj->hexdigest })->join; | |
20 | ||
21 | isnt $obj->clone->hexdigest, $tdigest, "unshared object unaffected by the thread"; | |
22 | ||
23 | $obj->add("bar"); | |
24 | is $obj->clone->hexdigest, $tdigest; |