root/lang/perl/Aspect/trunk/t/lib/Test/Class/MethodInfo.pm @ 9731

Revision 9731, 0.9 kB (checked in by hanekomu, 5 years ago)

r6028@nbgr: marcel | 2008-04-18 16:09:30 +0200
lang/perl/Aspect: initial commit

  • Property svn:executable set to *
Line 
1#! /usr/bin/perl -Tw
2
3package Test::Class::MethodInfo;
4use 5.006;
5use strict;
6use warnings;
7use Carp;
8
9our $VERSION = '0.01';
10
11sub is_method_type {
12        my ($self, $type) = @_;
13        return($type =~ m/^(startup|setup|test|teardown|shutdown)$/s);
14};
15
16sub is_num_tests {
17        my ($self, $num_tests) = @_;
18        return($num_tests =~ m/^(no_plan)|(\+?\d+)$/s);
19};
20
21sub new {
22    my ($class, %param) = @_;
23        my $self = bless {
24            name => $param{name},
25            type => $param{type} || 'test',
26        }, $class;
27        unless ( defined( $param{num_tests} ) ) {
28        $param{num_tests} = $self->is_type('test') ? 1 : 0;
29    };
30        $self->num_tests( $param{num_tests} );
31        return($self);
32};
33
34sub name { shift->{name} };
35
36sub num_tests   {
37        my ($self, $n) = @_;
38        if (defined($n)) {
39                croak "$n not valid number of tests"
40                                unless $self->is_num_tests($n);
41                $self->{_num_tests} = $n;
42        };
43        return($self->{_num_tests});
44};
45
46sub is_type {
47        my ($self, $type) = @_;
48    $self->{type} eq $type;
49};
50
51
521;
Note: See TracBrowser for help on using the browser.