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)(?:-SETUP)? # ... when we find a =begin test or testing
31 .*? # ... and keep capturing
32 \n=end[ \t]+(?:test|testing)(?:-SETUP)? # ... until an =end tag
34 (?:\n|$) # ... at the end of file or a newline
35 ) # ... and stop capturing
41 while ( $self->{source} =~ m/$search/go ) {
44 # A hack to turn the SYNOPSIS into something Test::Inline
46 if ( $elt =~ s/=head1[ \t]+SYNOPSIS/=begin testing-SETUP\n\n{/ ) {
47 $elt .= "}\n\n=end testing-SETUP";
50 # It seems like search.cpan doesn't like a name with
51 # spaces after =begin. bleah, what a mess.
52 $elt =~ s/testing-SETUP/testing SETUP/g;
57 # If we have just one element it's a SYNOPSIS, so there's no
59 return unless @elements > 1;
61 if ( @elements && $self->{source} =~ /=head1 NAME\n\n(Moose::Cookbook\S+)/ ) {
62 unshift @elements, 'package ' . $1 . ';';
65 (List::Util::first { /^=/ } @elements) ? \@elements : '';
72 use base 'Test::Inline::Content::Default';
77 my $base = $self->SUPER::process(@_);
79 $base =~ s/(\$\| = 1;)/use Test::Exception;\n$1/;
89 my $target = 't/000_recipes';
91 for my $t_file ( File::Find::Rule->file->name(qr/^moose_cookbook_\.t$/)->in($target) ) {
92 unlink $t_file or die "Cannot unlink $t_file: $!";
95 my $inline = Test::Inline->new(
99 ExtractHandler => 'My::Extract',
100 ContentHandler => 'My::Content',
104 File::Find::Rule->file->name(qr/\.pod$/)->in('lib/Moose/Cookbook') ) {