⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parser.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 3 页
字号:
If a SKIP directive is included with the plan, this method will return it. 1..0 # SKIP: why bother?=head3 C<explanation> my $explanation = $result->explanation;If a SKIP directive was included with the plan, this method will return theexplanation, if any.=head2 C<commment> methods if ( $result->is_comment ) { ... }If the above evaluates as true, the following methods will be available on theC<$result> object.=head3 C<comment>  if ( $result->is_comment ) {      my $comment = $result->comment;      print "I have something to say:  $comment";  }=head2 C<bailout> methods if ( $result->is_bailout ) { ... }If the above evaluates as true, the following methods will be available on theC<$result> object.=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" viathis method.  The explanation is the text after the mystical "Bail out!" wordswhich appear in the tap output.=head2 C<unknown> methods if ( $result->is_unknown ) { ... }There are no unique methods for unknown results.=head2 C<test> methods if ( $result->is_test ) { ... }If the above evaluates as true, the following methods will be available on theC<$result> object.=head3 C<ok>  my $ok = $result->ok;Returns the literal text of the C<ok> or C<not ok> status.=head3 C<number>  my $test_number = $result->number;Returns the number of the test, even if the original TAP output did not supplythat number.=head3 C<description>  my $description = $result->description;Returns the description of the test, if any.  This is the portion after thetest number but before the directive.=head3 C<directive>  my $directive = $result->directive;Returns either C<TODO> or C<SKIP> if either directive was present for a testline.=head3 C<explanation>  my $explanation = $result->explanation;If a test had either a C<TODO> or C<SKIP> directive, this method will returnthe accompanying explantion, if present.  not ok 17 - 'Pigs can fly' # TODO not enough acidFor the above line, the explanation is I<not enough acid>.=head3 C<is_ok>  if ( $result->is_ok ) { ... }Returns a boolean value indicating whether or not the test passed.  Rememberthat for TODO tests, the test always passes.B<Note:>  this was formerly C<passed>.  The latter method is deprecated andwill issue a warning.=head3 C<is_actual_ok>  if ( $result->is_actual_ok ) { ... }Returns a boolean value indicating whether or not the test passed, regardlessof its TODO status.B<Note:>  this was formerly C<actual_passed>.  The latter method is deprecatedand will issue a warning.=head3 C<is_unplanned>  if ( $test->is_unplanned ) { ... }If a test number is greater than the number of planned tests, this method willreturn true.  Unplanned tests will I<always> return false for C<is_ok>,regardless of whether or not the test C<has_todo> (seeL<TAP::Parser::Result::Test> for more information about this).=head3 C<has_skip>  if ( $result->has_skip ) { ... }Returns a boolean value indicating whether or not this test had a SKIPdirective.=head3 C<has_todo>  if ( $result->has_todo ) { ... }Returns a boolean value indicating whether or not this test had a TODOdirective.Note that TODO tests I<always> pass.  If you need to know whether or notthey really passed, check the C<is_actual_ok> method.=head3 C<in_todo>  if ( $parser->in_todo ) { ... }True while the most recent result was a TODO. Becomes true before theTODO result is returned and stays true until just before the next non-TODO test is returned.=head1 TOTAL RESULTSAfter parsing the TAP, there are many methods available to let you dig throughthe results and determine what is meaningful to you.=head2 Individual ResultsThese results refer to individual tests which are run.=head3 C<passed> my @passed = $parser->passed; # the test numbers which passed my $passed = $parser->passed; # the number of tests which passedThis method lets you know which (or how many) tests passed.  If a test failedbut had a TODO directive, it will be counted as a passed test.=cutsub passed { @{ shift->{passed} } }=head3 C<failed> my @failed = $parser->failed; # the test numbers which failed my $failed = $parser->failed; # the number of tests which failedThis method lets you know which (or how many) tests failed.  If a test passedbut had a TODO directive, it will B<NOT> be counted as a failed test.=cutsub failed { @{ shift->{failed} } }=head3 C<actual_passed> # the test numbers which actually passed my @actual_passed = $parser->actual_passed; # the number of tests which actually passed my $actual_passed = $parser->actual_passed;This method lets you know which (or how many) tests actually passed,regardless of whether or not a TODO directive was found.=cutsub actual_passed { @{ shift->{actual_passed} } }*actual_ok = \&actual_passed;=head3 C<actual_ok>This method is a synonym for C<actual_passed>.=head3 C<actual_failed> # the test numbers which actually failed my @actual_failed = $parser->actual_failed; # the number of tests which actually failed my $actual_failed = $parser->actual_failed;This method lets you know which (or how many) tests actually failed,regardless of whether or not a TODO directive was found.=cutsub actual_failed { @{ shift->{actual_failed} } }##############################################################################=head3 C<todo> my @todo = $parser->todo; # the test numbers with todo directives my $todo = $parser->todo; # the number of tests with todo directivesThis method lets you know which (or how many) tests had TODO directives.=cutsub todo { @{ shift->{todo} } }=head3 C<todo_passed> # the test numbers which unexpectedly succeeded my @todo_passed = $parser->todo_passed; # the number of tests which unexpectedly succeeded my $todo_passed = $parser->todo_passed;This method lets you know which (or how many) tests actually passed but weredeclared as "TODO" tests.=cutsub todo_passed { @{ shift->{todo_passed} } }##############################################################################=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 unexpectedlysucceeded.  Will now issue a warning and call C<todo_passed>.=cutsub todo_failed {    warn      '"todo_failed" is deprecated.  Please use "todo_passed".  See the docs.';    goto &todo_passed;}=head3 C<skipped> my @skipped = $parser->skipped; # the test numbers with SKIP directives my $skipped = $parser->skipped; # the number of tests with SKIP directivesThis method lets you know which (or how many) tests had SKIP directives.=cutsub skipped { @{ shift->{skipped} } }=head2 Summary ResultsThese results are "meta" information about the total results of an individualtest program.=head3 C<plan> my $plan = $parser->plan;Returns the test plan, if found.=head3 C<good_plan>Deprecated.  Use C<is_good_plan> instead.=cutsub good_plan {    warn 'good_plan() is deprecated.  Please use "is_good_plan()"';    goto &is_good_plan;}##############################################################################=head3 C<is_good_plan>  if ( $parser->is_good_plan ) { ... }Returns a boolean value indicating whether or not the number of tests plannedmatches the number of tests run.B<Note:>  this was formerly C<good_plan>.  The latter method is deprecated andwill issue a warning.And since we're on that subject ...=head3 C<tests_planned>  print $parser->tests_planned;Returns the number of tests planned, according to the plan.  For example, aplan of '1..17' will mean that 17 tests were planned.=head3 C<tests_run>  print $parser->tests_run;Returns the number of tests which actually were run.  Hopefully this willmatch the number of C<< $parser->tests_planned >>.=head3 C<skip_all>Returns a true value (actually the reason for skipping) if all testswere skipped.=head3 C<start_time>Returns the time when the Parser was created.=head3 C<end_time>Returns the time when the end of TAP input was seen.=head3 C<has_problems>  if ( $parser->has_problems ) {      ...  }This is a 'catch-all' method which returns true if any tests have currentlyfailed, any TODO tests unexpectedly succeeded, or any parse errors occurred.=cutsub has_problems {    my $self = shift;    return         $self->failed      || $self->parse_errors      || $self->wait      || $self->exit;}=head3 C<version>  $parser->version;Once the parser is done, this will return the version number for theparsed TAP. Version numbers were introduced with TAP version 13 so if noversion number is found version 12 is assumed.=head3 C<exit>  $parser->exit;Once the parser is done, this will return the exit status.  If the parser ranan executable, it returns the exit status of the executable.=head3 C<wait>  $parser->wait;Once the parser is done, this will return the wait status.  If the parser ranan executable, it returns the wait status of the executable.  Otherwise, thismererely returns the C<exit> status.=head3 C<parse_errors> my @errors = $parser->parse_errors; # the parser errors my $errors = $parser->parse_errors; # the number of parser_errorsFortunately, all TAP output is perfect.  In the event that it is not, thismethod will return parser errors.  Note that a junk line which the parser doesnot recognize is C<not> an error.  This allows this parser to handle futureversions of TAP.  The following are all TAP errors reported by the parser:=over 4=item * Misplaced planThe plan (for example, '1..5'), must only come at the beginning or end of theTAP output.=item * No planGotta have a plan!=item * More than one plan 1..3 ok 1 - input file opened not ok 2 - first line of the input valid # todo some data ok 3 read the rest of the file 1..3Right.  Very funny.  Don't do that.=item * Test numbers out of sequence 1..3 ok 1 - input file opened not ok 2 - first line of the input valid # todo some data ok 2 read the rest of the fileThat last test line above should have the number '3' instead of '2'.Note that it's perfectly acceptable for some lines to have test numbers andothers to not have them.  However, when a test number is found, it must be insequence.  The following is also an error: 1..3 ok 1 - input file opened not ok - first line of the input valid # todo some data ok 2 read the rest of the fileBut this is not: 1..3 ok  - input file opened not ok - first line of the input valid # todo some data ok 3 read the rest of the file=back=cutsub parse_errors { @{ shift->{parse_errors} } }sub _add_error {    my ( $self, $error ) = @_;    push @{ $self->{parse_errors} } => $error;    return $self;}sub _make_state_table {    my $self = shift;    my %states;    my %planned_todo = ();    #聽These transitions are defaults for all states    my %state_globals = (        comment => {},        bailout => {},        version => {            act => sub {                my ($version) = @_;                $self->_add_error(                    'If TAP version is present it must be the first line of output'                );            },        },    );    # Provides default elements for transitions    my %state_defaults = (        plan => {            act => sub {                my ($plan) = @_;                $self->tests_planned( $plan->tests_planned );                $self->plan( $plan->plan );                if ( $plan->has_skip ) {                    $self->skip_all( $plan->explanation                          || '(no reason given)' );                }                $planned_todo{$_}++ for @{ $plan->todo_list };            },        },        test => {            act => sub {                my ($test) = @_;                my ( $number, $tests_run )                  = ( $test->number, ++$self->{tests_run} );                # Fake TODO state                if ( defined $number && delete $planned_todo{$number} ) {                    $test->set_directive('TODO');                }                my $has_todo = $test->has_todo;                $self->in_todo($has_todo);                if ( defined( my $tests_planned = $self->tests_planned ) ) {                    if ( $tests_run > $tests_planned ) {                        $test->is_unplanned(1);                    }                }                if ($number) {                    if ( $number != $tests_run ) {                        my $count = $tests_run;                        $self->_add_error( "Tests out of sequence.  Found "                              . "($number) but expected ($count)" );                    }                }                else {                    $test->_number( $number = $tests_run );                }                push @{ $self->{todo} } => $number if $has_todo;                push @{ $self->{todo_passed} } => $number                  if $test->todo_passed;                push @{ $self->{skipped} } => $number                  if $test->has_skip;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -