Skip to content

Commit

Permalink
Fix comment block parsing, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadeusz Sośnierz committed Jul 7, 2011
1 parent 571755c commit 40859e6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -290,7 +290,11 @@ class Perl6::Actions is HLL::Actions {

method raw_block($/) {
my $type;
my $str := $*ST.add_constant('Str', 'str', $<pod_content>.Str);
my $str := $*ST.add_constant(
'Str', 'str',
pir::isa($<pod_content>, 'ResizablePMCArray')
?? pir::join('', $<pod_content>) !! ~$<pod_content>,
);
my $content := $*ST.add_constant(
'Array', 'type_new',
$str<compile_time_value>
Expand Down
41 changes: 41 additions & 0 deletions t/pod/05-comment.t
@@ -0,0 +1,41 @@
use Test;
plan 9;
my $r;

=begin pod
=for comment
foo foo
bla bla bla
This isn't a comment
=end pod

$r = $POD[0];
isa_ok $r.content[0], Pod__Block__Comment;
is $r.content[0].content.elems, 1;
is $r.content[0].content, "foo foo\nbla bla bla\n";

# from S26
=comment
This file is deliberately specified in Perl 6 Pod format

$r = $POD[1];
isa_ok $r, Pod__Block__Comment;
is $r.content.elems, 1;
is $r.content[0],
"This file is deliberately specified in Perl 6 Pod format\n";

# this happens to break hilighting in some editors,
# so I put it at the end
=begin comment
foo foo
=begin invalid pod
=as many invalid pod as we want
===yay!
=end comment
$r = $POD[2];
isa_ok $r, Pod__Block;
is $r.content.elems, 1;
is $r.content[0], "foo foo\n=begin invalid pod\n"
~ "=as many invalid pod as we want\n===yay!\n";

0 comments on commit 40859e6

Please sign in to comment.