diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-08 22:21:52 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-08 22:21:52 +0000 |
commit | 2f253cfc85ffd55a8acb988e91f0bc5ab348124c (patch) | |
tree | 4734ccd522c71dd455879162006742002f8c1565 /t/threads.t | |
download | HTML-Parser-tarball-2f253cfc85ffd55a8acb988e91f0bc5ab348124c.tar.gz |
HTML-Parser-3.71HEADHTML-Parser-3.71master
Diffstat (limited to 't/threads.t')
-rw-r--r-- | t/threads.t | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/t/threads.t b/t/threads.t new file mode 100644 index 0000000..8da91e9 --- /dev/null +++ b/t/threads.t @@ -0,0 +1,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); + |