File: 50_legacy.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 (60 lines) | stat: -rw-r--r-- 1,090 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
59
60
#!/usr/bin/perl

# Does the legacy compatibility interface Aspect::Legacy work as expected

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

use Test::More tests => 8;
use Test::NoWarnings;
use Aspect::Legacy;





######################################################################
# Before 

SCOPE: {
	package Person;

	use Test::More;

	sub get_foo {
		my $self = shift;
		is_deeply( [ @_ ], [ 'bar', 1, 2, 3 ], 'Params modified' );
		return 'foo';
	}

	package Tester;

	use Test::More;

	sub run_tests {
		my $person = bless { }, 'Person';
		my $foo    = $person->get_foo('bar');
		is( $foo, 'foo', 'Got the correct value' );
	}

	1;
}

my $CALLED = 0;
before {
	$CALLED++;
	my $context = shift;
	is(     $context->type,        'before', '->type ok' );
	isa_ok( $context->self,        'Person' );
	is(     $context->params->[1], 'bar', '->params ok' );
	is( ref($context->original), 'CODE', '->original ok' );
	$context->append_param(1);
	$context->append_params(2, 3);
} call qr/^Person::get_/
& cflow tester => 'Tester::run_tests';

Tester::run_tests();
is( $CALLED, 1, 'Hook fired' );