Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / threads.t
diff --git a/dev/i386/libhtml-parser-perl/libhtml-parser-perl-3.56/t/threads.t b/dev/i386/libhtml-parser-perl/libhtml-parser-perl-3.56/t/threads.t
new file mode 100644 (file)
index 0000000..8da91e9
--- /dev/null
@@ -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);
+