summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm
blob: 62bb7f2441bff97652232a49fdeee21b6b78693d (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# $Header: /home/fergal/my/cvs/Test-Tester/lib/Test/Tester/CaptureRunner.pm,v 1.3 2003/03/05 01:07:55 fergal Exp $
use strict;

#warn "Test::Tester::CaptureRunner is deprecated, see Test::Tester2\n";

package Test::Tester::CaptureRunner;

use Test::Tester::Capture;
require Exporter;

sub new {
    my $pkg = shift;
    my $self = bless {}, $pkg;
    return $self;
}

sub run_tests {
    my $self = shift;

    my $test = shift;

    capture()->reset;

    $self->{StartLevel} = $Test::Builder::Level;
    &$test();
}

sub get_results {
    my $self    = shift;
    my @results = capture()->details;

    my $start = $self->{StartLevel};
    foreach my $res (@results) {
        next if defined $res->{depth};
        my $depth = $res->{_depth} - $res->{_level} - $start - 3;
        $res->{depth} = $depth;
    }

    return @results;
}

sub get_premature {
    return capture()->premature;
}

sub capture {
    return Test::Tester::Capture->new;
}

__END__

=head1 NAME

Test::Tester::CaptureRunner - *DEPRECATED* Help testing test modules built with Test::Builder

=head1 DEPRECATED

See L<Test::Tester2> for a modern and maintained alternative.

=head1 DESCRIPTION

This stuff if needed to allow me to play with other ways of monitoring the
test results.

=head1 AUTHOR

Copyright 2003 by Fergal Daly <fergal@esatclear.ie>.

=head1 LICENSE

Under the same license as Perl itself

See http://www.perl.com/perl/misc/Artistic.html

=cut