On Tue, Sep 18, 2001 at 06:26:03PM -0600, chromatic wrote:
> In article <20010918185441.J585@blackrider>, "Michael G Schwern"
> <[EMAIL PROTECTED]> wrote:
> 
> > It's on my TODO list to decouple the guts of Test::Simple from the external
> > functions, so it's easier to write Test modules based on it, but it's about
> > two or three levels down on the list.
> 
> What might this entail?  If you can describe it in sufficient detail, I'd be
> happy to take a poke at it.

Oh... basically having a Test::Builder object.  The two main abilities
being that it can do the basic ok() for you, and you can tell it how
many call stacks to skip.

I envision, for example, is() being rewritten like so:

    package Test::More;
    require Test::Builder;

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

    # Tell it there's one level of calls between it and where the real test
    # is coming from.
    $Test->caller(1);

    sub is ($$;$) {
        my($this, $that, $name) = @_;

        my $test;
        {
            local $^W = 0;
            $test = $this eq $that;
        }

        my $ok = $Test->ok($test, $name);

        unless( $ok ) {
            $this = defined $this ? "'$this'" : 'undef';
            $that = defined $that ? "'$that'" : 'undef';

            # diagnostic takes care of indenting and putting the #
            # on it for you.
            $Test->diagnostic(sprintf <<DIAGNOSTIC, $this, $that);
         got: %s
    expected: %s
    DIAGNOSTIC
        }

        return $ok;
    }

Test::Simple would be almost entirely gutted and placed into
Test::Builder.  Test::Simple::ok() would become:

    $Test->caller(1);
    sub ok {
        return $Test->ok(@_);
    }

Most of it's exit logic would be in Test::Builder::END()

    END {
        $Test->END;
    }

In the end, most of Test::More's functions would be turned into
Test::Builder methods as well, and Test::More becomes a thin wrapper.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <[EMAIL PROTECTED]>       Kwalitee Is Job One
"Let's face it," said bearded Rusty Simmons, opening a can after the
race.  "This is a good excuse to drink some beer."  At 10:30 in the
morning?  "Well, it's past noon in Dublin," said teammate Mike
[Joseph] Schwern.  "It's our duty."
    -- "Sure, and It's a Great Day for Irish Runners" 
       Newsday, Sunday, March 20, 1988

Reply via email to