Test::Inline::Content - Test::Inline 2 Content Handlers


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

Index


Code Index:

NAME

Top

Test::Inline::Content - Test::Inline 2 Content Handlers

DESCRIPTION

Top

One problem with the initial versions of Test::Inline 2 was the method by which it generated the script contents.

Test::Inline::Content provides a basic API by which more sophisticated extensions can be written to control the content of the generated scripts.

METHODS

Top

new

A default implementation of the new method is provided that takes no parameters and creates a default (empty) object.

Returns a new Test::Inline::Content object.

process $Inline $Script

The process method does the work of generating the script content. It takes as argument the parent Test::Inline object, and the completed Test::Inline::Script object for which the file is to be generated.

The default implementation returns only an empty script that dies with an appropriate error message.

Returns the content of the script as a string, or undef on error.

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;

use strict;
use Params::Util '_INSTANCE';

use vars qw{$VERSION};
BEGIN {
	$VERSION = '2.212';
}

sub new {
	my $class = ref $_[0] || $_[0];
	bless {}, $class;
}

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

	# If used directly, create a valid script file that just dies
	my $class   = $Script->class;
	my $content = <<"END_PERL";
#!/usr/bin/perl

use strict;
use Test::More tests => 1;

fail('Generation of inline test script for $class failed' );

exit(0);
END_PERL

	return $content;
}

1;