I'm getting into testing a lot more lately and I realize that Test::More
doesn't do what I would like it to do and thus I'm creating my own test
class.  I took the code from Test::More namely the _export_to_level(),
plan(), import(), and builder().  I know what builder is doing so I don't
need any help there.  I am also including the 

 

require Exporter;

use vars ...

$VERSION ...

@ISA ...

@EXPORT ...

 

lines in my code.  Any help on what these lines and sub routines do or mean
would be greatly appreciated.  Thank you for your time.

 

---------------------------------------------------

Andrew Potozniak

Administrative Computing

Student Assistant

State University of New York at Buffalo

 <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]

645-3587 x 7123

---------------------------------------------------

 

Here is the code that I am using:

 

use 5.004;

 

use strict;

use Test::Builder;

 

require Exporter;

use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO);

#I believe this tells us the version of the perl module that I'm writing.

$VERSION = '0.01';

@ISA    = qw(Exporter);

 

#I think this tells what we can export

@EXPORT = qw(ok 

             is isnt like unlike

             skip todo todo_skip

             pass fail

             $TODO

             plan

             diag

            );

 

my $Test = Test::Builder->new;

 

 

#I have no idea what this does

sub _export_to_level

{

      my $pkg = shift;

      my $level = shift;

      (undef) = shift;                  # redundant arg

      my $callpkg = caller($level);

      $pkg->export($callpkg, @_);

}

 

sub plan {

    my(@plan) = @_;

 

    my $caller = caller;

    

    $Test->exported_to($caller);

 

    my @imports = ();

    foreach my $idx (0..$#plan) {

        if( $plan[$idx] eq 'import' ) {

            my($tag, $imports) = splice @plan, $idx, 2;

            @imports = @$imports;

            last;

        }

    }

 

    $Test->plan(@plan);

 

    __PACKAGE__->_export_to_level(1, __PACKAGE__, @imports);

}

 

#I think this gets called when use MY::Module; is seen.

sub import {

    my($class) = shift;

    goto &plan;

}

 

sub builder {

    return Test::Builder->new;

}

 

 

Reply via email to