root/branches/release-40/t/lib/Test/Deep/All.pm @ 2583

Revision 2583, 0.7 kB (checked in by mpaschal, 18 months ago)

Add Test::Deep to t/lib, since we already use it in driver-tests.pl
BugzID: 79953

Line 
1use strict;
2use warnings;
3
4package Test::Deep::All;
5
6use Test::Deep::Cmp;
7
8use overload
9        '&' => \&add,
10        fallback => 1,
11;
12
13sub init
14{
15        my $self = shift;
16
17        my @list = map {Test::Deep::wrap($_)} @_;
18
19        $self->{val} = \@list;
20}
21
22sub descend
23{
24        my $self = shift;
25        my $got = shift;
26
27        my $data = $self->data;
28
29        my $index = 1;
30
31        foreach my $cmp (@{$self->{val}})
32        {
33                $data->{index} = $index;
34                $index++;
35
36                next if Test::Deep::descend($got, $cmp);
37                return 0
38        }
39
40        return 1;
41}
42
43sub render_stack
44{
45        my $self = shift;
46        my $var = shift;
47        my $data = shift;
48
49        my $max = @{$self->{val}};
50
51        return "(Part $data->{index} of $max in $var)";
52}
53
54sub add
55{
56        my $self = shift;
57        my $expect = shift;
58
59        push(@{$self->{val}}, Test::Deep::wrap($expect));
60
61        return $self;
62}
63
641;
Note: See TracBrowser for help on using the browser.