File: Meta.pm

package info (click to toggle)
libfennec-perl 2.018-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 384 kB
  • sloc: perl: 2,083; makefile: 2
file content (86 lines) | stat: -rw-r--r-- 1,929 bytes parent folder | download | duplicates (4)
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
76
77
78
79
80
81
82
83
84
85
86
package Test::Workflow::Meta;
use strict;
use warnings;

use Test::Workflow::Layer;
use Test::Builder;

use Fennec::Util qw/accessors/;

accessors qw{
    test_class build_complete root_layer test_run test_wait test_sort ok diag
    skip todo_start todo_end control_store
};

sub new {
    my $class = shift;
    my ($test_class) = @_;

    my $tb = "tb";

    my $root_layer = Test::Workflow::Layer->new();

    my $self = bless(
        {
            test_class  => $test_class,
            root_layer  => $root_layer,
            ok          => Fennec::Util->can("${tb}_ok"),
            diag        => Fennec::Util->can("${tb}_diag"),
            skip        => Fennec::Util->can("${tb}_skip"),
            todo_start  => Fennec::Util->can("${tb}_todo_start"),
            todo_end    => Fennec::Util->can("${tb}_todo_end"),
            layer_stack => [$root_layer],
        },
        $class
    );

    return $self;
}

my @LAYER_STACK;

sub push_layer {
    my $self = shift;
    push @LAYER_STACK => @_;
}

sub pop_layer {
    my $self    = shift;
    my ($check) = @_;
    my $layer   = pop @LAYER_STACK;
    die "Bad pop!" unless $layer == $check;
    return $layer;
}

sub peek_layer {
    my $self = shift;
    return $LAYER_STACK[-1];
}

1;

__END__

=head1 NAME

Test::Workflow::Meta - The meta-object added to all Test-Workflow test classes.

=head1 DESCRIPTION

When you C<use Test::Workflow> a function is added to you class named
'TEST_WORKFLOW' that returns the single Test-Workflow meta-object that tracks
information about your class.

=head1 AUTHORS

Chad Granum L<exodist7@gmail.com>

=head1 COPYRIGHT

Copyright (C) 2013 Chad Granum

Test-Workflow is free software; Standard perl license.

Test-Workflow is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.