Patch up weird MRO fail on 5.8 perls
[dbsrgits/DBIx-Class.git] / t / 04dont_break_c3.t
1 use warnings;
2 use strict;
3
4 use Test::More;
5 use MRO::Compat;
6
7 use lib qw(t/lib);
8 use DBICTest; # do not remove even though it is not used
9
10 {
11   package AAA;
12
13   use base "DBIx::Class::Core";
14 }
15
16 {
17   package BBB;
18
19   use base 'AAA';
20
21   #Injecting a direct parent.
22   __PACKAGE__->inject_base( __PACKAGE__, 'AAA' );
23 }
24
25 {
26   package CCC;
27
28   use base 'AAA';
29
30   #Injecting an indirect parent.
31   __PACKAGE__->inject_base( __PACKAGE__, 'DBIx::Class::Core' );
32 }
33
34 eval { mro::get_linear_isa('BBB'); };
35 ok (! $@, "Correctly skipped injecting a direct parent of class BBB");
36
37 eval { mro::get_linear_isa('CCC'); };
38 ok (! $@, "Correctly skipped injecting an indirect parent of class BBB");
39
40 use DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server;
41 use B;
42
43 is_deeply (
44   mro::get_linear_isa('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server'),
45   [qw/
46     DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server
47     DBIx::Class::Storage::DBI::Sybase
48     DBIx::Class::Storage::DBI::MSSQL
49     DBIx::Class::Storage::DBI::UniqueIdentifier
50     DBIx::Class::Storage::DBI
51     DBIx::Class::Storage::DBIHacks
52     DBIx::Class::Storage
53     DBIx::Class
54     DBIx::Class::Componentised
55     Class::C3::Componentised
56     Class::Accessor::Grouped
57   /],
58   'Correctly ordered ISA of DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server'
59 );
60
61 my $dialect_ref = DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server->can('sql_limit_dialect');
62 is (
63   B::svref_2object($dialect_ref)->GV->STASH->NAME,
64   'DBIx::Class::Storage::DBI::MSSQL',
65   'Correct method picked'
66 );
67
68 done_testing;