The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Perlbug::Test- Perlbug testing module

DESCRIPTION

Utility functions for Perlbug test scripts, several wrappers for the email side of things...

Output is seen from output() when TEST_VERBOSE is set to 1, or when the script is being run directly.

Will set mailing to 0, meaning mails will be printed, rather than sent.

Set the current admin to the userid of the local bugmaster.

SYNOPSIS

        use Perlbug::Base;
        use Perlbug::Test; # calls Test;

        my $o_email = Perlbug::Base->new; 
        my $o_test  = Perlbug::Test->new($o_base);

        plan('todo' => 1); 

        my %header  = ('To' => 'perlbug@perl.org');
        my $o_int   = $o_email->setup_int(\%header, 'mail body perl');

        my ($switch, $msg) = $o_email->parse_mail($o_int);
        if ($switch eq 'B') {
                ok($test);
                output("passed");
        } else {
                notok($test);
                output("failed".Dumper($o_int));
        }

METHODS

new

Create new Perlbug::Test object.

Sets current(isatest=>1, admin=>$bugmaster):

    my $o_test = Perlbug::Test->new();              # generic

        my $o_email_test = Perlbug::Test->new($o_email); # guess :-)
output

prints given args with newline, warns if $Perlbug::DEBUG set

        output("message"); 
compare

Compare two arrays: returns 1 if identical, 0 if not.

    my $identical = $o_test->compare(\@arry1, \@arry2);
 

Utilities

    Provides mapping for default email content, passes back up to $o_email.

    target

            my $random_target_address = $o_test->target

    forward

            my $random_forward_address = $o_test->forward

AUTOLOAD

Tends to return member variables or, (where this is not supported), wraps any unhandlable calls to $o_arg->$meth(), where $o_arg is the Perlbug::Interface::Xxx->new object given by new() (see above);

bugdb
        my $bugdb = $o_test->email('bugdb');
bugid
        my $test_bugid = $o_test->bugid
domain
        my $test_domain = $o_test->domain
body
        my $test_body = $o_test->body
etc.

and so on

REDUNDANT

iseven

Return 0(odd) or 1(even) based on last number of given filename

        my $num = iseven($filename);
isodd

Return 1(odd) or 0(even) based on last number of given filename

        my $num = isodd($filename);
okbyfilearg

Return 1(ok) or 0(not) based on filename and arg, where arg just has to be successful in some way.

        $i_isok = okbyfilearg('test0.tst', 1); # false (0) 

        $i_isok = okbyfilearg('test1.tst', 1); # true  (1) 

        $i_isok = okbyfilearg('test2.tst', 0); # true  (1)

        $i_isok = okbyfilearg('test3.tst', 0); # false (0)
get_tests

Wraps getting test material filenames from test directory, incorporates test count and check that all expected types are found.

        my @tests = get_tests($t_dir, qw(this that and the other)); 

Fails if expected directory list or any files not found.

file2minet

Return Mail Iinternet object from dir,file:

Or undef:

        my $o_int = file2minet($filename);
minet2args

Wrapper to return args from Mail Internet object, ready for method check_mail(@args)

Or ();

        my @args = minet2args($o_int);  
minet2tagline

Returns X-Perlbug-Tag and X-Perlbug-Line headers from Mail Internet object:

Or ();

Instead of:

        my ($o_hdr, $header, $body) = $self->splice($o_int);
        my $tag  = $o_hdr->get('X-Perlbug-Tag')  || '';
        my $line = $o_hdr->get('X-Perlbug-Line') || '';

You can:

        my ($tag, $line) = minet2tagline($o_int);
check_mail

Check headers against various given parameters, attempts to read all required lines/data.

        my ($o_hdr, $header, $body) = $o_mail->splice($o_int);
        my @should         = $o_hdr->get('X-Perlbug-Match');
        my @shouldnt   = $o_hdr->get('X-Perlbug-Match-Non');
        my @shouldfail = $o_hdr->get('X-Perlbug-Match-Bad');

        ($i_ok, $feedback) = $o_bugmail->check_mail($o_new, $body, \@should, \@shouldnt, \@shouldfail); 
        
        warn "Mail check failure($i_ok): ($feedback)\n" unless $i_ok == 1;

AUTHOR

Richard Foley perlbug@rfi.net 2000 2001

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 172:

You can't have =items (as at line 176) unless the first thing after the =over is an =item

Around line 218:

'=item' outside of any '=over'

Around line 259:

You forgot a '=back' before '=head1'