Commit | Line | Data |
89847188 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | BEGIN { |
5 | if ($ENV{'PERL_CORE'}){ |
6 | chdir('t'); |
7 | unshift(@INC, '../lib'); |
8 | } |
89847188 |
9 | } |
10 | |
11 | use Thread::Semaphore; |
12 | |
13 | use Test::More 'tests' => 12; |
14 | |
15 | my $err = qr/^Semaphore .* is not .* integer: /; |
16 | |
17 | eval { Thread::Semaphore->new(undef); }; |
18 | like($@, $err, $@); |
19 | eval { Thread::Semaphore->new(0.5); }; |
20 | like($@, $err, $@); |
21 | eval { Thread::Semaphore->new('foo'); }; |
22 | like($@, $err, $@); |
23 | |
24 | my $s = Thread::Semaphore->new(); |
25 | ok($s, 'New semaphore'); |
26 | |
27 | eval { $s->down(undef); }; |
28 | like($@, $err, $@); |
29 | eval { $s->down(-1); }; |
30 | like($@, $err, $@); |
31 | eval { $s->down(1.5); }; |
32 | like($@, $err, $@); |
33 | eval { $s->down('foo'); }; |
34 | like($@, $err, $@); |
35 | |
36 | eval { $s->up(undef); }; |
37 | like($@, $err, $@); |
38 | eval { $s->up(-1); }; |
39 | like($@, $err, $@); |
40 | eval { $s->up(1.5); }; |
41 | like($@, $err, $@); |
42 | eval { $s->up('foo'); }; |
43 | like($@, $err, $@); |
44 | |
45 | # EOF |