File: 12_pointcut_cflow.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 (58 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl

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

use Test::More tests => 14;
use Aspect;

SCOPE: {
	package My::Foo;

	sub parent1 {
		$_[0]->child;
	}

	sub parent2 {
		$_[0]->child;
	}

	sub child {
		return 1;
	}
}

my $MATCHES = 0;

# Set up the cflow hook
around {
	$MATCHES += 1;
	isa_ok( $_->{foo}, 'Aspect::Point::Static' );
	isa_ok( $_->foo, 'Aspect::Point::Static' );
	$_->proceed;
	$_->return_value(2);
} call 'My::Foo::child'
& cflow foo => 'My::Foo::parent2';

is( My::Foo->child,   1, '->child ok'   );
is( My::Foo->parent1, 1, '->parent1 ok' );
is( My::Foo->parent2, 2, '->parent2 ok' );
is( $MATCHES, 1, 'Got one match total' );

# Set up a second single-param cflow hook
around {
	$MATCHES += 10;
	isa_ok( $_->{enclosing}, 'Aspect::Point::Static' );
	isa_ok( $_->enclosing, 'Aspect::Point::Static' );
	$_->proceed;
	$_->return_value(3);
} call 'My::Foo::child'
& cflow 'My::Foo::parent1';

is( My::Foo->child,   1, '->child ok'   );
is( My::Foo->parent1, 3, '->parent1 ok' );
is( My::Foo->parent2, 2, '->parent2 ok' );
is( $MATCHES, 12, 'Got expected matches' );