f782cd6fbae6933c9576c55e42ea6bbeef4ff839
[gitmo/Class-C3-XS.git] / t / 34_next_method_in_eval.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 2;
7
8 BEGIN {
9     use lib 'opt', '../opt', '..';    
10     use_ok('c3');
11 }
12
13 =pod
14
15 This tests the use of an eval{} block to wrap a next::method call.
16
17 =cut
18
19 {
20     package A;
21     use c3; 
22
23     sub foo {
24       die 'A::foo died';
25       return 'A::foo succeeded';
26     }
27 }
28
29 {
30     package B;
31     use base 'A';
32     use c3; 
33     
34     sub foo {
35       eval {
36         return 'B::foo => ' . (shift)->next::method();
37       };
38
39       if ($@) {
40         return $@;
41       }
42     }
43 }
44
45 Class::C3::initialize();  
46
47 like(B->foo, 
48    qr/^A::foo died/, 
49    'method resolved inside eval{}');
50
51