9 use base 'Test::Inline::Extract';
11 # This extracts the SYNOPSIS in addition to code specifically
14 (?:^|\n) # After the beginning of the string, or a newline
15 ( # ... start capturing
17 package\s+ # A package
18 [^\W\d]\w*(?:(?:\'|::)[^\W\d]\w*)* # ... with a name
19 \s*; # And a statement terminator
21 =head1[ \t]+SYNOPSIS\n
25 =for[ \t]+example[ \t]+begin\n # ... when we find a =for example begin
26 .*? # ... and keep capturing
27 \n=for[ \t]+example[ \t]+end\s*? # ... until the =for example end
28 (?:\n|$) # ... at the end of file or a newline
30 =begin[ \t]+(?:test|testing)\b # ... when we find a =begin test or testing
31 .*? # ... and keep capturing
32 \n=end[ \t]+(?:test|testing)\s*? # ... until an =end tag
33 (?:\n|$) # ... at the end of file or a newline
34 ) # ... and stop capturing
40 while ( $self->{source} =~ m/$search/go ) {
43 # A hack to turn the SYNOPSIS into something Test::Inline
45 if ( $elt =~ s/=head1[ \t]+SYNOPSIS/=begin testing SETUP\n\n{/ ) {
46 $elt .= "}\n\n=end testing SETUP";
52 # If we have just one element it's a SYNOPSIS, so there's no
54 return unless @elements > 1;
56 if ( @elements && $self->{source} =~ /=head1 NAME\n\n(Moose::Cookbook\S+)/ ) {
57 unshift @elements, 'package ' . $1 . ';';
60 (List::Util::first { /^=/ } @elements) ? \@elements : '';
67 use base 'Test::Inline::Content::Default';
72 my $base = $self->SUPER::process(@_);
74 $base =~ s/(\$\| = 1;)/use Test::Exception;\n$1/;
84 my $target = 't/000_recipes';
86 for my $t_file ( File::Find::Rule->file->name(qr/^moose_cookbook_\.t$/)->in($target) ) {
87 unlink $t_file or die "Cannot unlink $t_file: $!";
90 my $inline = Test::Inline->new(
94 ExtractHandler => 'My::Extract',
95 ContentHandler => 'My::Content',
99 File::Find::Rule->file->name(qr/\.pod$/)->in('lib/Moose/Cookbook') ) {