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/textarea.t | |
download | HTML-Parser-tarball-master.tar.gz |
HTML-Parser-3.71HEADHTML-Parser-3.71master
Diffstat (limited to 't/textarea.t')
-rw-r--r-- | t/textarea.t | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/t/textarea.t b/t/textarea.t new file mode 100644 index 0000000..120f79b --- /dev/null +++ b/t/textarea.t @@ -0,0 +1,70 @@ +use Test::More tests => 1; + +use strict; +use HTML::Parser; + +my $html = <<'EOT'; +<html> +<title>This is a <nice> title</title> +<!--comment--> +<script language="perl">while (<DATA>) { & }</script> + +<FORM> + +<textarea name="foo" cols=50 rows=10> + +foo +<foo> +<!--comment--> +& +foo +</FORM> + +</textarea> + +</FORM> + +</html> +EOT + +my $dump = ""; +sub tdump { + my @a = @_; + for (@a) { + $_ = "<undef>" unless defined; + s/\n/\\n/g; + } + $dump .= join("|", @a) . "\n"; +} + +my $p = HTML::Parser->new(default_h => [\&tdump, "event,text,dtext,is_cdata"]); +$p->parse($html)->eof; + +#diag $dump; + +is($dump, <<'EOT'); +start_document||<undef>|<undef> +start|<html>|<undef>|<undef> +text|\n|\n| +start|<title>|<undef>|<undef> +text|This is a <nice> title|This is a <nice> title| +end|</title>|<undef>|<undef> +text|\n|\n| +comment|<!--comment-->|<undef>|<undef> +text|\n|\n| +start|<script language="perl">|<undef>|<undef> +text|while (<DATA>) { & }|while (<DATA>) { & }|1 +end|</script>|<undef>|<undef> +text|\n\n|\n\n| +start|<FORM>|<undef>|<undef> +text|\n\n|\n\n| +start|<textarea name="foo" cols=50 rows=10>|<undef>|<undef> +text|\n\nfoo\n<foo>\n<!--comment-->\n&\nfoo\n</FORM>\n\n|\n\nfoo\n<foo>\n<!--comment-->\n&\nfoo\n</FORM>\n\n| +end|</textarea>|<undef>|<undef> +text|\n\n|\n\n| +end|</FORM>|<undef>|<undef> +text|\n\n|\n\n| +end|</html>|<undef>|<undef> +text|\n|\n| +end_document||<undef>|<undef> +EOT |