adding the some preliminary junk
[gitmo/Class-C3-XS.git] / t / 21_C3_with_overload.t
CommitLineData
8995e827 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 8;
7
8BEGIN {
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
35Class::C3::initialize();
36
37my $x = InheritingFromOverloadedTest->new();
38isa_ok($x, 'InheritingFromOverloadedTest');
39
40my $y = OverloadingTest->new();
41isa_ok($y, 'OverloadingTest');
42
43is("$x", 'InheritingFromOverloadedTest stringified', '... got the right value when stringifing');
44is("$y", 'OverloadingTest stringified', '... got the right value when stringifing');
45
46ok(($y eq 'OverloadingTest stringified'), '... eq was handled correctly');
47
48my $result;
49eval {
50 $result = $x eq 'InheritingFromOverloadedTest stringified'
51};
52ok(!$@, '... this should not throw an exception');
53ok($result, '... and we should get the true value');
54
55#use Data::Dumper;
56#diag Dumper { Class::C3::_dump_MRO_table }