# vi:filetype= use Test::Base; use JavaScript::SpiderMonkey; use JSON::XS; #use Test::LongString; #use Data::Structure; use utf8; use Encode; my $json_xs = JSON::XS->new->allow_nonref; plan tests => blocks() * 1; my $jsfile = 'js/pod2html.js'; my $monkey = new JavaScript::SpiderMonkey; $monkey->init(); open my $in, $jsfile or die "Failed to open JS file $jsfile: $!\n"; my $js = do { local $/; <$in> }; close $in; $monkey->eval($js) or die "Failed to load $jsfile: $@"; my $res; $monkey->function_set('get', sub { $res = shift }); run { my $block = shift; my $name = $block->name; my $pod = $block->pod or die "No -- pod specified for $name"; my $json = $json_xs->encode($pod); $monkey->eval("get(pod2html($json))") or die "Error occured when calling the pod2html function: $@"; $res = Encode::decode('utf8', $res); is "$res\n", $block->html, "$name - HTML output okay"; }; $monkey->destroy(); __DATA__ === TEST 1: =image --- pod =image gate.jpg --- html

hi
=== TEST 3: Lhttp://agentzh.org/#elem/home/1
=== TEST 4: indented paragraphs work --- pod hello world --- htmlhello world=== TEST 5: head1 & indented text --- pod =head1 A B C hello world --- html
hello world=== TEST 6: head3 & normal paragraphs --- pod =head3 hi hello, world Ahah! dog is here. --- html
hello, world Ahah!
dog is here.
=== TEST 7: C<...> works --- pod Chello, world
/usr/bin/perl
=== TEST 9: I<...> works --- pod She loves IShe loves me!
=== TEST 10: B<...> works --- pod She loves BShe loves me!
=== TEST 11: over & =item * --- pod =over 4 =item * Hello, world *grin* =back --- html*grin*
abc
hello
hello
English words
Oh oh!
2>3 F I B
3 > 4 532aa=== TEST 20: head4 works --- pod =head4 你好么 ABC --- html
really?
hello, world haha
Heh, that's cool!
=== TEST 23: =begin HTML & =end HTML --- pod =begin HTML Hello, worldHeh, that's cool!
=== TEST 24: =begin HTML & =end html --- pod =head1 header =begin HTML Hello, worldHeh, that's cool!
=== TEST 25: =begin comment & =end comment --- pod =head1 header =begin comment Hello, worldHeh, that's cool!