File: keep_going.t

package info (click to toggle)
libsuper-perl 1.20120705-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 132 kB
  • ctags: 9
  • sloc: perl: 424; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!perl

BEGIN
{
	chdir 't' if -d 't';
}

use lib '../lib';

use strict;
use warnings;

use Test::More tests => 4;

# so being able to say super() once is neat, but I want to super all
# the way back up to the root of the tree

package Grandfather;

Test::More->import();

sub foo
{
	pass( "Called on the Grandfather" );
	return 42;
}

package Father;

Test::More->import();

use SUPER;
use base qw( Grandfather );
my $called;

sub foo
{
	die "Recursed on Father (should have called Grandfather)"
		if ++$called > 1;

	pass( "Called on the Father" );
	super;
}

package Son;

Test::More->import();

use SUPER;
use base qw( Father );

sub foo
{
	pass( "Called on the Son" );
	super;
}

package main;

is( Son->foo(), 42, "called the Son->Father->Grandfather" );