Adam Spiers <[EMAIL PROTECTED]> writes:

> Piers Cawley ([EMAIL PROTECTED]) wrote:
> > Adam Spiers <[EMAIL PROTECTED]> writes:
> > You're assuming here that file/line is meaningful, which isn't
> > necessarily the case in dynamically generated code. (Like, oooh, inner
> > classes...) And there's nothing to stop us collecting that information
> > anyway. 
> 
> True.
> 
> > I'm not sure what you mean by your (b). There's no guaranteed method
> > of parsing back to the beginning of the appropriate test_* method so
> > if you want to get the whole method you end up having to do
> > scattershot methods to increase the amount of context grabbed.
> 
> That's right.  I was thinking you could just do something like spawn
> "less +$line $file", and then leave the user to choose what to look at.
> 
> > '1e1' eq '10'; # ''
> > '1e1' == '10'; # 1
> 
> Sure, but:
> 
>   sub equal {
>     my ($a, $b) = @_;
>     return $a eq $b;
>   }
> 
>   print equal('1e1', '10') ? 'equal' : 'not equal', "\n";
>   print equal( 1e1  , 10 ) ? 'equal' : 'not equal', "\n";
> 
> does the right thing.
> 
> >      $str_match = sub { $_[0] eq $_[1] or die "Expected $_[0], got $_[1]\n" }
> >      $numeric = sub { $_[0] == $_[1] or die "Expected $_[0], got $_[1]\n" }
> > 
> >      $self->assert($str_match, "Foo", "Bar");
> >      $self->assert($numeric, 10, 11);
> > 
> > Simple, functional, doesn't add any more methods to Test::Unit::Assert
> > and friends. Which is nice.
> 
> Ahhhh.  Now that *is* nice.  You should have shown it earlier - it
> persuaded me almost instantly :-)  Somehow the previous discussion on
> this topic gave me the impression that the interface would be a lot
> more complicated.
> 
> So, this system has my vote.  I have a few minor concerns which I
> would like to see sorted out first though.
> 
> Firstly:
> 
> $ make test
> PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib 
>-I/usr/lib/perl5/5.00503/i386-linux -I/usr/lib/perl5/5.00503 -e 'use Test::Harness 
>qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
> t/all_tests.........(This error is expected) Suite class Test::Unit::tests::AllTests 
>not found: Can't load '/usr/lib/perl5/5.00503/i386-linux/auto/B/B.so' for module B: 
>/usr/lib/perl5/5.00503/i386-linux/auto/B/B.so: undefined symbol: Perl_byterun at 
>/usr/lib/perl5/5.00503/i386-linux/DynaLoader.pm line 169.
> 
>  at /usr/lib/perl5/5.00503/i386-linux/B/Deparse.pm line 11
> BEGIN failed--compilation aborted at /usr/lib/perl5/5.00503/i386-linux/B/Deparse.pm 
>line 11.
> BEGIN failed--compilation aborted at lib/Test/Unit/Assertion/CodeRef.pm line 10.
> BEGIN failed--compilation aborted at lib/Test/Unit/tests/AllTests.pm line 5.
> dubious
>         Test returned status 2 (wstat 512, 0x200)
> Undefined subroutine &Test::Harness::WCOREDUMP called at 
>/usr/lib/perl5/5.00503/Test/Harness.pm line 288.
> make: *** [test_dynamic] Error 2
> 
> 
> I suspect this is due to my system having an old, default RedHat (and
> hence broken) rpm of Perl.  Nevertheless, for various unavoidable
> reasons, PerlUnit is not much use to me right now unless it works with
> this rpm.  There may even be people who would like to use PerlUnit
> with perls old enough that they don't have B::Deparse in the core
> distribution.  Can it be tweaked to load B::Deparse on demand?  I'd
> like to see an example of B::Deparse in action before I'm convinced of
> its usefulness.  (There should maybe be some way of choosing its
> options via the runner?  Thread merge ...)

perl -MCPAN -e "install 'B::Deparse'", which isn't guaranteed to work
for older perls I'm afraid. I thought I'd set PREREQ_PM to include
B::Deparse, but it shouldn't be too hard to code things so that you
don't *have* to have B::Deparse to get things working (fall back to
file and linenumber for example) 

> 
> Secondly, how would an assertion using
> 
> >      $str_match = sub { $_[0] eq $_[1] or die "Expected $_[0], got $_[1]\n" }
> >      $numeric = sub { $_[0] == $_[1] or die "Expected $_[0], got $_[1]\n" }
> 
> distinguish between an exception raised within a test_method
> (e.g. die() if loading of fixture failed) and a failure?

sub Test::Unit::Assertion::CodeRef::do_assert {
    my $self = shift;
    my $possible_object = shift;
    $possible_object->$$self(@_) ||
        $self->fail("$possible_object\->{$self}(" .
                    join (", ", @_) .
                    ") failed" . ($@ ? "with error $@." : "."));
}

If the code dies, then its $@ is caught and appended to the message
passed into the 'fail' method. If you get a die during fixture
generation then it wouldn't get caught in this fashion. 

> 
> Finally, various minor coding issues:
> 
>   - Bits of pod need updating/writing to reflect the changes.

Yup.

> 
>   - T::U::Assertion and T::U::Assert both seem to be missing a
> 
>       use Test::Unit::ExceptionFailure

Make that

        require Test::Unit::ExceptionFailure

and I'll agree with you. You shouldn't really go around 'use'ing
class files unless you know they have an import method that you want
to make use of..

>     line, and they duplicate the fail() method.  Do we need both
>     classes?

Well, I'm not entirely sure what Test::Unit::Assert is doing there.
AFAICT it doesn't really do anything. Not sure what effect getting rid
of it, or rolling some of its functionality into Test::Unit::Test
would have though.

-- 
Piers


_______________________________________________
Perlunit-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/perlunit-devel

Reply via email to