File: threads.t

package info (click to toggle)
libhtml-parser-perl 3.56-1%2Blenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 536 kB
  • ctags: 192
  • sloc: ansic: 1,985; perl: 1,935; makefile: 43
file content (39 lines) | stat: -rw-r--r-- 569 bytes parent folder | download | duplicates (5)
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
29
30
31
32
33
34
35
36
37
38
39
# Verify thread safety.

use Config;
use Test::More;

BEGIN {
    plan(skip_all => "Not configured for threads")
	unless $Config{useithreads} && $] >= 5.008;
    plan(tests => 1);
}

use threads;
use HTML::Parser;

my $ok=0;

sub start
{
    my($tag,$attr)=@_;

    $ok += ($tag eq "foo");
    $ok += (defined($attr->{param}) && $attr->{param} eq "bar");
}

my $p = HTML::Parser->new
    (api_version => 3,
     handlers => {
	 start => [\&start, "tagname,attr"],
     });

$p->parse("<foo pa");

$ok=async {
    $p->parse("ram=bar>");
    $ok;
}->join();

is($ok,2);