File: threads.t

package info (click to toggle)
libhash-multivalue-perl 0.16-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 270; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 581 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use Config;
use Test::More;
use Hash::MultiValue;

BEGIN {
    plan skip_all => "perl interpreter is not compiled with ithreads"
      unless $Config{useithreads};

    plan skip_all => "perl 5.8.1 required for thread tests"
      unless $] > '5.0080009';

    require threads;
}

plan tests => 2;

my $h = Hash::MultiValue->new(foo => 'bar');
my @exp = ('bar');

is_deeply([$h->get_all('foo')], \@exp, 'got expected results');

my @got = threads->create(sub { 
    $h->get_all('foo');
})->join;

is_deeply(\@got, \@exp, 'got expected results in cloned interpreter');