Test::Inline::Content::Default - Test::Inline 2 fallback/default Content Handler


Test-Inline documentation Contained in the Test-Inline distribution.

Index


Code Index:

NAME

Top

Test::Inline::Content::Default - Test::Inline 2 fallback/default Content Handler

DESCRIPTION

Top

This class implements the default generator for script content. It generates test script content inteded for use in a standard CPAN dist.

This module contains no user servicable parts.

SUPPORT

Top

See the main SUPPORT section.

AUTHOR

Top

Adam Kennedy <adamk@cpan.org>, http://ali.as/

COPYRIGHT

Top


Test-Inline documentation Contained in the Test-Inline distribution.
package Test::Inline::Content::Default;

use strict;
use Params::Util qw{_INSTANCE};
use Test::Inline::Content ();

use vars qw{$VERSION @ISA};
BEGIN {
	$VERSION = '2.212';
	@ISA = 'Test::Inline::Content';
}

sub process {
	my $self   = shift;
	my $Inline = _INSTANCE(shift, 'Test::Inline')         or return undef;
	my $Script = _INSTANCE(shift, 'Test::Inline::Script') or return undef;

	# Get the merged content
	my $content = $Script->merged_content;
	return undef unless defined $content;

	# Determine a plan
	my $tests = $Script->tests;
	my $plan  = defined $tests
		? "tests => $tests"
		: "'no_plan'";

	# Wrap the merged contents with the rest of the test
	# file infrastructure.
	my $file = <<"END_TEST";
#!/usr/bin/perl -w

use strict;
use Test::More $plan;
\$| = 1;



$content



1;
END_TEST

	$file;
}

1;