# -*- Mode: cperl; cperl-indent-level: 4 -*-
package Test
::Harness
::Point
;
Test::Harness::Point - object for tracking a single test point
One Test::Harness::Point object represents a single test point.
my $point = new Test::Harness::Point;
Create a test point object.
my $self = bless {}, $class;
my $test_line_regex = qr/
(?:\s+(\d+))? # optional test number
=head1 from_test_line( $line )
Constructor from a TAP test line, or empty return if the test line
my $line = shift or return;
# We pulverize the line down into pieces in three parts.
my ($not, $number, $extra) = ($line =~ $test_line_regex ) or return;
$point->set_number( $number );
my ($description,$directive) = split( /(?:[^\\]|^)#/, $extra, 2 );
$description =~ s/^- //; # Test::More puts it in there
$point->set_description( $description );
$point->set_directive( $directive );
Each of the following fields has a getter and setter method.
sub ok { my $self = shift; $self->{ok} }
$self->{ok} = $ok ? 1 : 0;
return ($self->ok || $self->is_todo || $self->is_skip) ? 1 : 0;
sub number { my $self = shift; $self->{number} }
sub set_number { my $self = shift; $self->{number} = shift }
sub description { my $self = shift; $self->{description} }
$self->{description} = shift;
$self->{name} = $self->{description}; # history
sub directive { my $self = shift; $self->{directive} }
$self->{directive} = $directive;
my ($type,$reason) = ($directive =~ /^\s*(\S+)(?:\s+(.*))?$/);
$self->set_directive_type( $type );
$reason = "" unless defined $reason;
$self->{directive_reason} = $reason;
$self->{directive_type} = lc shift;
$self->{type} = $self->{directive_type}; # History
sub set_directive_reason {
$self->{directive_reason} = shift;
sub directive_type { my $self = shift; $self->{directive_type} }
sub type { my $self = shift; $self->{directive_type} }
sub directive_reason{ my $self = shift; $self->{directive_reason} }
sub reason { my $self = shift; $self->{directive_reason} }
my $type = $self->directive_type;
return $type && ( $type eq 'todo' );
my $type = $self->directive_type;
return $type && ( $type eq 'skip' );
return @{$self->{diagnostics}} if wantarray;
return join( "\n", @{$self->{diagnostics}} );
sub add_diagnostic { my $self = shift; push @{$self->{diagnostics}}, @_ }