]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blob - lib/Test/Valgrind/Command/Aggregate.pm
Add a new T::V::Command::Aggregate that aggregates several commands together
[perl/modules/Test-Valgrind.git] / lib / Test / Valgrind / Command / Aggregate.pm
1 package Test::Valgrind::Command::Aggregate;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 Test::Valgrind::Command::Aggregate - A Test::Valgrind command that aggregates several other commands.
9
10 =head1 VERSION
11
12 Version 1.01
13
14 =cut
15
16 our $VERSION = '1.01';
17
18 =head1 DESCRIPTION
19
20 =cut
21
22 use Scalar::Util ();
23
24 use base qw/Test::Valgrind::Command Test::Valgrind::Carp/;
25
26 =head1 METHODS
27
28 This class inherits L<Test::Valgrind::Command>.
29
30 =head2 C<< new commands => \@commands, ... >>
31
32 =cut
33
34 my $all_cmds = sub {
35  for (@{$_[0]}) {
36   return 0 unless Scalar::Util::blessed($_)
37                                          and $_->isa('Test::Valgrind::Command');
38  }
39  return 1;
40 };
41
42 sub new {
43  my $class = shift;
44  $class = ref($class) || $class;
45
46  my %args = @_;
47
48  my $cmds = delete $args{commands};
49  $class->_croak('Invalid commands list')
50                    unless $cmds and ref $cmds eq 'ARRAY' and $all_cmds->($cmds);
51
52  my $self = bless $class->SUPER::new(), $class;
53
54  $self->{commands} = [ @$cmds ];
55
56  $self;
57 }
58
59 =head2 C<commands>
60
61 Read-only accessor for the C<commands> option.
62
63 =cut
64
65 sub commands { @{$_[0]->{commands} || []} }
66
67 =head1 SEE ALSO
68
69 L<Test::Valgrind>, L<Test::Valgrind::Command>.
70
71 =head1 AUTHOR
72
73 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
74
75 You can contact me by mail or on C<irc.perl.org> (vincent).
76
77 =head1 BUGS
78
79 Please report any bugs or feature requests to C<bug-test-valgrind at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
80 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
81
82 =head1 SUPPORT
83
84 You can find documentation for this module with the perldoc command.
85
86     perldoc Test::Valgrind::Command::Aggregate
87
88 =head1 COPYRIGHT & LICENSE
89
90 Copyright 2009 Vincent Pit, all rights reserved.
91
92 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
93
94 =cut
95
96 1; # End of Test::Valgrind::Command::Aggregate