adding the some preliminary junk
[gitmo/Class-C3-XS.git] / t / 21_C3_with_overload.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 8;
7
8 BEGIN {
9     use_ok('Class::C3');
10 }
11
12 {
13     package BaseTest;
14     use strict;
15     use warnings;
16     use Class::C3;
17     
18     package OverloadingTest;
19     use strict;
20     use warnings;
21     use Class::C3;
22     use base 'BaseTest';        
23     use overload '""' => sub { ref(shift) . " stringified" },
24                  fallback => 1;
25     
26     sub new { bless {} => shift }    
27     
28     package InheritingFromOverloadedTest;
29     use strict;
30     use warnings;
31     use base 'OverloadingTest';
32     use Class::C3;
33 }
34
35 Class::C3::initialize();
36
37 my $x = InheritingFromOverloadedTest->new();
38 isa_ok($x, 'InheritingFromOverloadedTest');
39
40 my $y = OverloadingTest->new();
41 isa_ok($y, 'OverloadingTest');
42
43 is("$x", 'InheritingFromOverloadedTest stringified', '... got the right value when stringifing');
44 is("$y", 'OverloadingTest stringified', '... got the right value when stringifing');
45
46 ok(($y eq 'OverloadingTest stringified'), '... eq was handled correctly');
47
48 my $result;
49 eval { 
50     $result = $x eq 'InheritingFromOverloadedTest stringified' 
51 };
52 ok(!$@, '... this should not throw an exception');
53 ok($result, '... and we should get the true value');
54
55 #use Data::Dumper;
56 #diag Dumper { Class::C3::_dump_MRO_table }