File: 72_wormhole.t

package info (click to toggle)
libaspect-perl 1.04-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 720 kB
  • sloc: perl: 6,846; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More tests => 3;
use Test::NoWarnings;
use Aspect;

# Do a lexical and make sure it produces lexical advice
SCOPE: {
	my $aspect = aspect Wormhole => 'One::a', 'Three::a';
	my $object = One->new;
	is( $object->a, $object, 'One::a returns instance of calling object' );
}

# Repeat using a global aspect and make sure it produces global advice
aspect Wormhole => 'One::b', 'Three::b';
my $object = One->new;
is( $object->b, $object, 'One::b returns instance of calling object' );

package One;

sub new {
	bless {}, shift;
}

sub a {
	Two->a;
}

sub b {
	Two->b;
}

package Two;

sub a {
	Three->a;
}

sub b {
	Three->b;
}

package Three;

sub a {
	pop;
}

sub b {
	pop;
}