r12983@zaphod: kd | 2008-04-28 18:10:27 +1000
[catagits/Catalyst-Runtime.git] / t / c3_mro.t
CommitLineData
b4664174 1use strict;
2use warnings;
3
4use Test::More;
5require Catalyst;
6require Module::Pluggable::Object;
7
8eval "require Class::C3";
9plan skip_all => "This test requires Class::C3" if $@;
10
11# Get a list of all Catalyst:: packages in blib via M::P::O
12my @cat_mods;
13{
2f381252 14 # problem with @INC on win32, see:
15 # http://rt.cpan.org/Ticket/Display.html?id=26452
16 if ($^O eq 'MSWin32') { require Win32; Win32::GetCwd(); }
17
b4664174 18 local @INC = grep {/blib/} @INC;
19 @cat_mods = (
ac5c933b 20 'Catalyst',
b4664174 21 Module::Pluggable::Object->new(search_path => ['Catalyst'])->plugins,
22 );
23}
24
25# plan one test per found package name
26plan tests => scalar @cat_mods;
27
28# Try to calculate the C3 MRO for each package
29#
30# In the case that the initial require fails (as in
31# Catalyst::Engine::FastCGI when FCGI is not installed),
32# the calculateMRO eval will not error out, which is
33# effectively a test skip.
34#
35foreach my $cat_mod (@cat_mods) {
36 eval " require $cat_mod ";
37 eval { Class::C3::calculateMRO($cat_mod) };
4ae6f108 38 ok(!$@, "calculateMRO for $cat_mod: $@");
b4664174 39}
40