r12983@zaphod: kd | 2008-04-28 18:10:27 +1000
[catagits/Catalyst-Runtime.git] / t / c3_mro.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 require Catalyst;
6 require Module::Pluggable::Object;
7
8 eval "require Class::C3";
9 plan skip_all => "This test requires Class::C3" if $@;
10
11 # Get a list of all Catalyst:: packages in blib via M::P::O
12 my @cat_mods;
13 {
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
18   local @INC = grep {/blib/} @INC;
19   @cat_mods = (
20     'Catalyst', 
21     Module::Pluggable::Object->new(search_path => ['Catalyst'])->plugins,
22   );
23 }
24
25 # plan one test per found package name
26 plan 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 #
35 foreach my $cat_mod (@cat_mods) {
36   eval " require $cat_mod ";
37   eval { Class::C3::calculateMRO($cat_mod) };
38   ok(!$@, "calculateMRO for $cat_mod: $@");
39 }
40