1
# -*- Mode: cperl; cperl-indent-level: 4 -*-
2
package Test::Harness::Point;
10
Test::Harness::Point - object for tracking a single test point
14
One Test::Harness::Point object represents a single test point.
20
my $point = new Test::Harness::Point;
22
Create a test point object.
28
my $self = bless {}, $class;
33
=head1 from_test_line( $line )
35
Constructor from a TAP test line, or empty return if the test line
42
my $line = shift or return;
44
# We pulverize the line down into pieces in three parts.
45
my ($not, $number, $extra) = ($line =~ /^(not )?ok\b(?:\s+(\d+))?\s*(.*)/) or return;
47
my $point = $class->new;
48
$point->set_number( $number );
49
$point->set_ok( !$not );
52
my ($description,$directive) = split( /(?:[^\\]|^)#/, $extra, 2 );
53
$description =~ s/^- //; # Test::More puts it in there
54
$point->set_description( $description );
56
$point->set_directive( $directive );
65
Each of the following fields has a getter and setter method.
75
sub ok { my $self = shift; $self->{ok} }
79
$self->{ok} = $ok ? 1 : 0;
84
return ($self->ok || $self->is_todo || $self->is_skip) ? 1 : 0;
87
sub number { my $self = shift; $self->{number} }
88
sub set_number { my $self = shift; $self->{number} = shift }
90
sub description { my $self = shift; $self->{description} }
93
$self->{description} = shift;
94
$self->{name} = $self->{description}; # history
97
sub directive { my $self = shift; $self->{directive} }
100
my $directive = shift;
102
$directive =~ s/^\s+//;
103
$directive =~ s/\s+$//;
104
$self->{directive} = $directive;
106
my ($type,$reason) = ($directive =~ /^\s*(\S+)(?:\s+(.*))?$/);
107
$self->set_directive_type( $type );
108
$reason = "" unless defined $reason;
109
$self->{directive_reason} = $reason;
111
sub set_directive_type {
113
$self->{directive_type} = lc shift;
114
$self->{type} = $self->{directive_type}; # History
116
sub set_directive_reason {
118
$self->{directive_reason} = shift;
120
sub directive_type { my $self = shift; $self->{directive_type} }
121
sub type { my $self = shift; $self->{directive_type} }
122
sub directive_reason{ my $self = shift; $self->{directive_reason} }
123
sub reason { my $self = shift; $self->{directive_reason} }
126
my $type = $self->directive_type;
127
return $type && ( $type eq 'todo' );
131
my $type = $self->directive_type;
132
return $type && ( $type eq 'skip' );
137
return @{$self->{diagnostics}} if wantarray;
138
return join( "\n", @{$self->{diagnostics}} );
140
sub add_diagnostic { my $self = shift; push @{$self->{diagnostics}}, @_ }