Front page | perl.perl5.porters |
Postings from August 2011
Tests for ‘Inconsistent MRO...’ (Re: GSOC Status Report, Week 6)
Thread Previous
|
Thread Next
From:
Father Chrysostomos
Date:
August 7, 2011 22:32
Subject:
Tests for ‘Inconsistent MRO...’ (Re: GSOC Status Report, Week 6)
Message ID:
3D579B4B-10C1-4EDF-AD22-3B2E5AB4CE48@cpan.org
On Aug 7, 2011, at 1:16 PM, Father Chrysostomos wrote:
>
> On Aug 3, 2011, at 11:42 PM, Brian Fraser wrote:
>
>> On Wed, Aug 3, 2011 at 11:00 AM, Nicholas Clark <nick@ccl4.org> wrote:
>> Ooooh, that doesn't seem to be tested anywhere. Fortunately Class::C3 on
>>
>> CPAN seems to have a test that that we can "borrow". I mean imitate.
>> Imitation being the sincerest form of flattery.
>>
>> (Assuming that you haven't written one between then and now. Likely this
>> belongs somewhere in ext/mro/t/)
>>
>>
>> I approve of such gallantry course of action! But rafl did write a test a couple of weeks back, though I guess it didn't make it into blead. I'll add it to ext/mro/t/ unless someone wants to commit it earlier?
>
> I’ll try and get to it some time....
Ahem. Look what I’ve just discovered:
$ cat t/mro/inconsistent_c3.t
#!./perl
use strict;
use warnings;
BEGIN {
unless (-d 'blib') {
chdir 't' if -d 't';
@INC = '../lib';
}
}
require q(./test.pl); plan(tests => 1);
require mro;
=pod
This example is take from: http://www.python.org/2.3/mro.html
"Serious order disagreement" # From Guido
class O: pass
class X(O): pass
class Y(O): pass
class A(X,Y): pass
class B(Y,X): pass
try:
class Z(A,B): pass #creates Z(A,B) in Python 2.2
except TypeError:
pass # Z(A,B) cannot be created in Python 2.3
=cut
{
package X;
package Y;
package XY;
our @ISA = ('X', 'Y');
package YX;
our @ISA = ('Y', 'X');
package Z;
our @ISA = ('XY', 'YX');
}
eval { mro::get_linear_isa('Z', 'c3') };
like($@, qr/^Inconsistent /, '... got the right error with an inconsistent hierarchy');
>
>>
>> Also, I think that none of the "*dir() attempted on invalid dirhandle %s" warnings are tested anywhere, so if someone gets around adding the mro test, maybe add those too? Triggering the warning itself is trivial, but I assume the portability concerns are not: perl -we 'opendir my $dir, "."; closedir $dir; seekdir $dir, 0;'
>
> $ perl -we 'no warnings "once"; seekdir *foo, 0'
> seekdir() attempted on invalid dirhandle foo at -e line 1.
>
Thread Previous
|
Thread Next