Initial Commit
This commit is contained in:
62
database/perl/lib/TAP/Parser/Result/Bailout.pm
Normal file
62
database/perl/lib/TAP/Parser/Result/Bailout.pm
Normal file
@@ -0,0 +1,62 @@
|
||||
package TAP::Parser::Result::Bailout;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::Bailout - Bailout result token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if a bail out line is encountered.
|
||||
|
||||
1..5
|
||||
ok 1 - woo hooo!
|
||||
Bail out! Well, so much for "woo hooo!"
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
Mainly listed here to shut up the pitiful screams of the pod coverage tests.
|
||||
They keep me awake at night.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * C<as_string>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head2 Instance Methods
|
||||
|
||||
=head3 C<explanation>
|
||||
|
||||
if ( $result->is_bailout ) {
|
||||
my $explanation = $result->explanation;
|
||||
print "We bailed out because ($explanation)";
|
||||
}
|
||||
|
||||
If, and only if, a token is a bailout token, you can get an "explanation" via
|
||||
this method. The explanation is the text after the mystical "Bail out!" words
|
||||
which appear in the tap output.
|
||||
|
||||
=cut
|
||||
|
||||
sub explanation { shift->{bailout} }
|
||||
sub as_string { shift->{bailout} }
|
||||
|
||||
1;
|
||||
60
database/perl/lib/TAP/Parser/Result/Comment.pm
Normal file
60
database/perl/lib/TAP/Parser/Result/Comment.pm
Normal file
@@ -0,0 +1,60 @@
|
||||
package TAP::Parser::Result::Comment;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::Comment - Comment result token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if a comment line is encountered.
|
||||
|
||||
1..1
|
||||
ok 1 - woo hooo!
|
||||
# this is a comment
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
Mainly listed here to shut up the pitiful screams of the pod coverage tests.
|
||||
They keep me awake at night.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * C<as_string>
|
||||
|
||||
Note that this method merely returns the comment preceded by a '# '.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head2 Instance Methods
|
||||
|
||||
=head3 C<comment>
|
||||
|
||||
if ( $result->is_comment ) {
|
||||
my $comment = $result->comment;
|
||||
print "I have something to say: $comment";
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
sub comment { shift->{comment} }
|
||||
sub as_string { shift->{raw} }
|
||||
|
||||
1;
|
||||
119
database/perl/lib/TAP/Parser/Result/Plan.pm
Normal file
119
database/perl/lib/TAP/Parser/Result/Plan.pm
Normal file
@@ -0,0 +1,119 @@
|
||||
package TAP::Parser::Result::Plan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::Plan - Plan result token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if a plan line is encountered.
|
||||
|
||||
1..1
|
||||
ok 1 - woo hooo!
|
||||
|
||||
C<1..1> is the plan. Gotta have a plan.
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
Mainly listed here to shut up the pitiful screams of the pod coverage tests.
|
||||
They keep me awake at night.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * C<as_string>
|
||||
|
||||
=item * C<raw>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head2 Instance Methods
|
||||
|
||||
=head3 C<plan>
|
||||
|
||||
if ( $result->is_plan ) {
|
||||
print $result->plan;
|
||||
}
|
||||
|
||||
This is merely a synonym for C<as_string>.
|
||||
|
||||
=cut
|
||||
|
||||
sub plan { '1..' . shift->{tests_planned} }
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<tests_planned>
|
||||
|
||||
my $planned = $result->tests_planned;
|
||||
|
||||
Returns the number of tests planned. For example, a plan of C<1..17> will
|
||||
cause this method to return '17'.
|
||||
|
||||
=cut
|
||||
|
||||
sub tests_planned { shift->{tests_planned} }
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<directive>
|
||||
|
||||
my $directive = $plan->directive;
|
||||
|
||||
If a SKIP directive is included with the plan, this method will return it.
|
||||
|
||||
1..0 # SKIP: why bother?
|
||||
|
||||
=cut
|
||||
|
||||
sub directive { shift->{directive} }
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<has_skip>
|
||||
|
||||
if ( $result->has_skip ) { ... }
|
||||
|
||||
Returns a boolean value indicating whether or not this test has a SKIP
|
||||
directive.
|
||||
|
||||
=head3 C<explanation>
|
||||
|
||||
my $explanation = $plan->explanation;
|
||||
|
||||
If a SKIP directive was included with the plan, this method will return the
|
||||
explanation, if any.
|
||||
|
||||
=cut
|
||||
|
||||
sub explanation { shift->{explanation} }
|
||||
|
||||
=head3 C<todo_list>
|
||||
|
||||
my $todo = $result->todo_list;
|
||||
for ( @$todo ) {
|
||||
...
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
sub todo_list { shift->{todo_list} }
|
||||
|
||||
1;
|
||||
62
database/perl/lib/TAP/Parser/Result/Pragma.pm
Normal file
62
database/perl/lib/TAP/Parser/Result/Pragma.pm
Normal file
@@ -0,0 +1,62 @@
|
||||
package TAP::Parser::Result::Pragma;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::Pragma - TAP pragma token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if a pragma is encountered.
|
||||
|
||||
TAP version 13
|
||||
pragma +strict, -foo
|
||||
|
||||
Pragmas are only supported from TAP version 13 onwards.
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
Mainly listed here to shut up the pitiful screams of the pod coverage tests.
|
||||
They keep me awake at night.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * C<as_string>
|
||||
|
||||
=item * C<raw>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head2 Instance Methods
|
||||
|
||||
=head3 C<pragmas>
|
||||
|
||||
if ( $result->is_pragma ) {
|
||||
@pragmas = $result->pragmas;
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
sub pragmas {
|
||||
my @pragmas = @{ shift->{pragmas} };
|
||||
return wantarray ? @pragmas : \@pragmas;
|
||||
}
|
||||
|
||||
1;
|
||||
271
database/perl/lib/TAP/Parser/Result/Test.pm
Normal file
271
database/perl/lib/TAP/Parser/Result/Test.pm
Normal file
@@ -0,0 +1,271 @@
|
||||
package TAP::Parser::Result::Test;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::Test - Test result token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if a test line is encountered.
|
||||
|
||||
1..1
|
||||
ok 1 - woo hooo!
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
This class is the workhorse of the L<TAP::Parser> system. Most TAP lines will
|
||||
be test lines and if C<< $result->is_test >>, then you have a bunch of methods
|
||||
at your disposal.
|
||||
|
||||
=head2 Instance Methods
|
||||
|
||||
=cut
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<ok>
|
||||
|
||||
my $ok = $result->ok;
|
||||
|
||||
Returns the literal text of the C<ok> or C<not ok> status.
|
||||
|
||||
=cut
|
||||
|
||||
sub ok { shift->{ok} }
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<number>
|
||||
|
||||
my $test_number = $result->number;
|
||||
|
||||
Returns the number of the test, even if the original TAP output did not supply
|
||||
that number.
|
||||
|
||||
=cut
|
||||
|
||||
sub number { shift->{test_num} }
|
||||
|
||||
sub _number {
|
||||
my ( $self, $number ) = @_;
|
||||
$self->{test_num} = $number;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<description>
|
||||
|
||||
my $description = $result->description;
|
||||
|
||||
Returns the description of the test, if any. This is the portion after the
|
||||
test number but before the directive.
|
||||
|
||||
=cut
|
||||
|
||||
sub description { shift->{description} }
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<directive>
|
||||
|
||||
my $directive = $result->directive;
|
||||
|
||||
Returns either C<TODO> or C<SKIP> if either directive was present for a test
|
||||
line.
|
||||
|
||||
=cut
|
||||
|
||||
sub directive { shift->{directive} }
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<explanation>
|
||||
|
||||
my $explanation = $result->explanation;
|
||||
|
||||
If a test had either a C<TODO> or C<SKIP> directive, this method will return
|
||||
the accompanying explanation, if present.
|
||||
|
||||
not ok 17 - 'Pigs can fly' # TODO not enough acid
|
||||
|
||||
For the above line, the explanation is I<not enough acid>.
|
||||
|
||||
=cut
|
||||
|
||||
sub explanation { shift->{explanation} }
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<is_ok>
|
||||
|
||||
if ( $result->is_ok ) { ... }
|
||||
|
||||
Returns a boolean value indicating whether or not the test passed. Remember
|
||||
that for TODO tests, the test always passes.
|
||||
|
||||
If the test is unplanned, this method will always return false. See
|
||||
C<is_unplanned>.
|
||||
|
||||
=cut
|
||||
|
||||
sub is_ok {
|
||||
my $self = shift;
|
||||
|
||||
return if $self->is_unplanned;
|
||||
|
||||
# TODO directives reverse the sense of a test.
|
||||
return $self->has_todo ? 1 : $self->ok !~ /not/;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<is_actual_ok>
|
||||
|
||||
if ( $result->is_actual_ok ) { ... }
|
||||
|
||||
Returns a boolean value indicating whether or not the test passed, regardless
|
||||
of its TODO status.
|
||||
|
||||
=cut
|
||||
|
||||
sub is_actual_ok {
|
||||
my $self = shift;
|
||||
return $self->{ok} !~ /not/;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<actual_passed>
|
||||
|
||||
Deprecated. Please use C<is_actual_ok> instead.
|
||||
|
||||
=cut
|
||||
|
||||
sub actual_passed {
|
||||
warn 'actual_passed() is deprecated. Please use "is_actual_ok()"';
|
||||
goto &is_actual_ok;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<todo_passed>
|
||||
|
||||
if ( $test->todo_passed ) {
|
||||
# test unexpectedly succeeded
|
||||
}
|
||||
|
||||
If this is a TODO test and an 'ok' line, this method returns true.
|
||||
Otherwise, it will always return false (regardless of passing status on
|
||||
non-todo tests).
|
||||
|
||||
This is used to track which tests unexpectedly succeeded.
|
||||
|
||||
=cut
|
||||
|
||||
sub todo_passed {
|
||||
my $self = shift;
|
||||
return $self->has_todo && $self->is_actual_ok;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<todo_failed>
|
||||
|
||||
# deprecated in favor of 'todo_passed'. This method was horribly misnamed.
|
||||
|
||||
This was a badly misnamed method. It indicates which TODO tests unexpectedly
|
||||
succeeded. Will now issue a warning and call C<todo_passed>.
|
||||
|
||||
=cut
|
||||
|
||||
sub todo_failed {
|
||||
warn 'todo_failed() is deprecated. Please use "todo_passed()"';
|
||||
goto &todo_passed;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<has_skip>
|
||||
|
||||
if ( $result->has_skip ) { ... }
|
||||
|
||||
Returns a boolean value indicating whether or not this test has a SKIP
|
||||
directive.
|
||||
|
||||
=head3 C<has_todo>
|
||||
|
||||
if ( $result->has_todo ) { ... }
|
||||
|
||||
Returns a boolean value indicating whether or not this test has a TODO
|
||||
directive.
|
||||
|
||||
=head3 C<as_string>
|
||||
|
||||
print $result->as_string;
|
||||
|
||||
This method prints the test as a string. It will probably be similar, but
|
||||
not necessarily identical, to the original test line. Directives are
|
||||
capitalized, some whitespace may be trimmed and a test number will be added if
|
||||
it was not present in the original line. If you need the original text of the
|
||||
test line, use the C<raw> method.
|
||||
|
||||
=cut
|
||||
|
||||
sub as_string {
|
||||
my $self = shift;
|
||||
my $string = $self->ok . " " . $self->number;
|
||||
if ( my $description = $self->description ) {
|
||||
$string .= " $description";
|
||||
}
|
||||
if ( my $directive = $self->directive ) {
|
||||
my $explanation = $self->explanation;
|
||||
$string .= " # $directive $explanation";
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head3 C<is_unplanned>
|
||||
|
||||
if ( $test->is_unplanned ) { ... }
|
||||
$test->is_unplanned(1);
|
||||
|
||||
If a test number is greater than the number of planned tests, this method will
|
||||
return true. Unplanned tests will I<always> return false for C<is_ok>,
|
||||
regardless of whether or not the test C<has_todo>.
|
||||
|
||||
Note that if tests have a trailing plan, it is not possible to set this
|
||||
property for unplanned tests as we do not know it's unplanned until the plan
|
||||
is reached:
|
||||
|
||||
print <<'END';
|
||||
ok 1
|
||||
ok 2
|
||||
1..1
|
||||
END
|
||||
|
||||
=cut
|
||||
|
||||
sub is_unplanned {
|
||||
my $self = shift;
|
||||
return ( $self->{unplanned} || '' ) unless @_;
|
||||
$self->{unplanned} = !!shift;
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
48
database/perl/lib/TAP/Parser/Result/Unknown.pm
Normal file
48
database/perl/lib/TAP/Parser/Result/Unknown.pm
Normal file
@@ -0,0 +1,48 @@
|
||||
package TAP::Parser::Result::Unknown;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::Unknown - Unknown result token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if the parser does not recognize the token line. For example:
|
||||
|
||||
1..5
|
||||
VERSION 7
|
||||
ok 1 - woo hooo!
|
||||
... woo hooo! is cool!
|
||||
|
||||
In the above "TAP", the second and fourth lines will generate "Unknown"
|
||||
tokens.
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
Mainly listed here to shut up the pitiful screams of the pod coverage tests.
|
||||
They keep me awake at night.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * C<as_string>
|
||||
|
||||
=item * C<raw>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
1;
|
||||
62
database/perl/lib/TAP/Parser/Result/Version.pm
Normal file
62
database/perl/lib/TAP/Parser/Result/Version.pm
Normal file
@@ -0,0 +1,62 @@
|
||||
package TAP::Parser::Result::Version;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::Version - TAP syntax version token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if a version line is encountered.
|
||||
|
||||
TAP version 13
|
||||
ok 1
|
||||
not ok 2
|
||||
|
||||
The first version of TAP to include an explicit version number is 13.
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
Mainly listed here to shut up the pitiful screams of the pod coverage tests.
|
||||
They keep me awake at night.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * C<as_string>
|
||||
|
||||
=item * C<raw>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head2 Instance Methods
|
||||
|
||||
=head3 C<version>
|
||||
|
||||
if ( $result->is_version ) {
|
||||
print $result->version;
|
||||
}
|
||||
|
||||
This is merely a synonym for C<as_string>.
|
||||
|
||||
=cut
|
||||
|
||||
sub version { shift->{version} }
|
||||
|
||||
1;
|
||||
61
database/perl/lib/TAP/Parser/Result/YAML.pm
Normal file
61
database/perl/lib/TAP/Parser/Result/YAML.pm
Normal file
@@ -0,0 +1,61 @@
|
||||
package TAP::Parser::Result::YAML;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'TAP::Parser::Result';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
TAP::Parser::Result::YAML - YAML result token.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.42
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '3.42';
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<TAP::Parser::Result>. A token of this class will be
|
||||
returned if a YAML block is encountered.
|
||||
|
||||
1..1
|
||||
ok 1 - woo hooo!
|
||||
|
||||
C<1..1> is the plan. Gotta have a plan.
|
||||
|
||||
=head1 OVERRIDDEN METHODS
|
||||
|
||||
Mainly listed here to shut up the pitiful screams of the pod coverage tests.
|
||||
They keep me awake at night.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * C<as_string>
|
||||
|
||||
=item * C<raw>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
##############################################################################
|
||||
|
||||
=head2 Instance Methods
|
||||
|
||||
=head3 C<data>
|
||||
|
||||
if ( $result->is_yaml ) {
|
||||
print $result->data;
|
||||
}
|
||||
|
||||
Return the parsed YAML data for this result
|
||||
|
||||
=cut
|
||||
|
||||
sub data { shift->{data} }
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user