From: Brandon L Black Date: Fri, 11 May 2007 15:18:30 +0000 (+0000) Subject: more tests, fixed is_universal X-Git-Tag: 0.02~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac5a5a7ffda684bc72010f2c2d59fa7df7237cae;p=gitmo%2FMRO-Compat.git more tests, fixed is_universal --- diff --git a/lib/MRO/Compat.pm b/lib/MRO/Compat.pm index b75a855..2607e81 100644 --- a/lib/MRO/Compat.pm +++ b/lib/MRO/Compat.pm @@ -274,7 +274,7 @@ sub __is_universal { my $classname = shift; die "mro::is_universal requires a classname" if !$classname; - my $lin = __get_linear_isa($classname); + my $lin = __get_linear_isa('UNIVERSAL'); foreach (@$lin) { return 1 if $classname eq $_; } diff --git a/t/10basic.t b/t/10basic.t index 8f9a118..355f4a8 100644 --- a/t/10basic.t +++ b/t/10basic.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 11; BEGIN { use_ok('MRO::Compat'); @@ -16,24 +16,36 @@ BEGIN { package EEE; our @ISA = qw/BBB CCC DDD/; package FFF; our @ISA = qw/EEE DDD/; package GGG; our @ISA = qw/FFF/; + package UNIVERSAL; our @ISA = qw/DDD/; } is_deeply( mro::get_linear_isa('GGG'), - [ 'GGG', 'FFF', 'EEE', 'BBB', 'AAA', 'CCC', 'DDD' ] + [ 'GGG', 'FFF', 'EEE', 'BBB', 'AAA', 'CCC', 'DDD' ], + "get_linear_isa for GGG", ); is_deeply( [mro::get_isarev('GGG')], [], + "get_isarev for GGG", ); is_deeply( [mro::get_isarev('DDD')], - [ 'EEE', 'FFF', 'GGG' ], + [ 'EEE', 'FFF', 'GGG', 'UNIVERSAL' ], + "get_isarev for DDD", ); is_deeply( [mro::get_isarev('AAA')], - [ 'BBB', 'CCC', 'DDD', 'EEE', 'FFF', 'GGG' ], + [ 'BBB', 'CCC', 'DDD', 'EEE', 'FFF', 'GGG', 'UNIVERSAL' ], + "get_isarev for AAA", ); + +ok(mro::is_universal('UNIVERSAL'), "UNIVERSAL is_universal"); +ok(mro::is_universal('DDD'), "DDD is_universal"); +ok(mro::is_universal('AAA'), "AAA is_universal"); +ok(!mro::is_universal('MRO::Compat'), "MRO::Compat !is_universal"); +ok(!mro::is_universal('BBB'), "BBB !is_universal"); +ok(!mro::is_universal('FFF'), "FFF !is_universal");