]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blob - lib/Test/Valgrind/Command/Aggregate.pm
This is 1.19
[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.19
13
14 =cut
15
16 our $VERSION = '1.19';
17
18 =head1 DESCRIPTION
19
20 This command groups several commands together, which the session will run under the same action.
21
22 =cut
23
24 use Scalar::Util ();
25
26 use base qw<Test::Valgrind::Command Test::Valgrind::Carp>;
27
28 =head1 METHODS
29
30 This class inherits L<Test::Valgrind::Command>.
31
32 =head2 C<new>
33
34     my $tvca = Test::Valgrind::Command::Aggregate->new(
35      commands => \@commands,
36      %extra_args,
37     );
38
39 =cut
40
41 my $all_cmds = sub {
42  for (@{$_[0]}) {
43   return 0 unless Scalar::Util::blessed($_)
44                                          and $_->isa('Test::Valgrind::Command');
45  }
46  return 1;
47 };
48
49 sub new {
50  my $class = shift;
51  $class = ref($class) || $class;
52
53  my %args = @_;
54
55  my $cmds = delete $args{commands};
56  $class->_croak('Invalid commands list')
57                    unless $cmds and ref $cmds eq 'ARRAY' and $all_cmds->($cmds);
58
59  my $self = bless $class->SUPER::new(), $class;
60
61  $self->{commands} = [ @$cmds ];
62
63  $self;
64 }
65
66 =head2 C<commands>
67
68     my @commands = $tvca->commands;
69
70 Read-only accessor for the C<commands> option.
71
72 =cut
73
74 sub commands { @{$_[0]->{commands} || []} }
75
76 =head1 SEE ALSO
77
78 L<Test::Valgrind>, L<Test::Valgrind::Command>.
79
80 =head1 AUTHOR
81
82 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
83
84 You can contact me by mail or on C<irc.perl.org> (vincent).
85
86 =head1 BUGS
87
88 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>.
89 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
90
91 =head1 SUPPORT
92
93 You can find documentation for this module with the perldoc command.
94
95     perldoc Test::Valgrind::Command::Aggregate
96
97 =head1 COPYRIGHT & LICENSE
98
99 Copyright 2009,2010,2011,2013,2015,2016 Vincent Pit, all rights reserved.
100
101 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
102
103 =cut
104
105 1; # End of Test::Valgrind::Command::Aggregate