| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Test::Stream::Event::Ok; | 
| 2 | 107 |  |  | 107 |  | 1124 | use strict; | 
|  | 107 |  |  |  |  | 186 |  | 
|  | 107 |  |  |  |  | 2772 |  | 
| 3 | 107 |  |  | 107 |  | 524 | use warnings; | 
|  | 107 |  |  |  |  | 185 |  | 
|  | 107 |  |  |  |  | 3106 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 107 |  |  | 107 |  | 538 | use Scalar::Util qw/blessed/; | 
|  | 107 |  |  |  |  | 192 |  | 
|  | 107 |  |  |  |  | 5481 |  | 
| 6 | 107 |  |  | 107 |  | 528 | use Carp qw/confess/; | 
|  | 107 |  |  |  |  | 203 |  | 
|  | 107 |  |  |  |  | 5324 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 107 |  |  | 107 |  | 57643 | use Test::Stream::Formatter::TAP qw/OUT_STD OUT_TODO OUT_ERR/; | 
|  | 107 |  |  |  |  | 244 |  | 
|  | 107 |  |  |  |  | 441 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 107 |  |  | 107 |  | 58045 | use Test::Stream::Event::Diag; | 
|  | 107 |  |  |  |  | 268 |  | 
|  | 107 |  |  |  |  | 850 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | use Test::Stream::Event( | 
| 13 | 107 |  |  |  |  | 559 | accessors => [qw/pass effective_pass name diag allow_bad_name/], | 
| 14 | 107 |  |  | 107 |  | 586 | ); | 
|  | 107 |  |  |  |  | 182 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub init { | 
| 17 | 3220 |  |  | 3220 | 0 | 4468 | my $self = shift; | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 3220 | 100 |  |  |  | 9161 | confess("No debug info provided!") unless $self->{+DEBUG}; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | # Do not store objects here, only true or false | 
| 22 | 3219 | 100 |  |  |  | 7931 | $self->{+PASS} = $self->{+PASS} ? 1 : 0; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 3219 |  | 100 |  |  | 12002 | $self->{+EFFECTIVE_PASS} = $self->{+PASS} || $self->{+DEBUG}->no_fail || 0; | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 3219 | 100 |  |  |  | 8021 | return if $self->{+ALLOW_BAD_NAME}; | 
| 27 | 3218 |  | 100 |  |  | 8041 | my $name = $self->{+NAME} || return; | 
| 28 | 3141 | 100 | 100 |  |  | 20782 | return unless index($name, '#') != -1 || index($name, "\n") != -1; | 
| 29 | 2 |  |  |  |  | 12 | $self->debug->throw("'$name' is not a valid name, names must not contain '#' or newlines.") | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | sub to_tap { | 
| 33 | 2934 |  |  | 2934 | 1 | 4178 | my $self = shift; | 
| 34 | 2934 |  |  |  |  | 4048 | my ($num) = @_; | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 2934 |  |  |  |  | 5411 | my $name  = $self->{+NAME}; | 
| 37 | 2934 |  |  |  |  | 4171 | my $debug = $self->{+DEBUG}; | 
| 38 | 2934 |  |  |  |  | 4523 | my $skip  = $debug->{skip}; | 
| 39 | 2934 |  |  |  |  | 4006 | my $todo  = $debug->{todo}; | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 2934 |  |  |  |  | 3926 | my $out = ""; | 
| 42 | 2934 | 100 |  |  |  | 6865 | $out .= "not " unless $self->{+PASS}; | 
| 43 | 2934 |  |  |  |  | 4005 | $out .= "ok"; | 
| 44 | 2934 | 100 |  |  |  | 7605 | $out .= " $num" if defined $num; | 
| 45 | 2934 | 100 |  |  |  | 7639 | $out .= " - $name" if $name; | 
| 46 |  |  |  |  |  |  |  | 
| 47 | 2934 | 100 | 100 |  |  | 12481 | if (defined $skip && defined $todo) { | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 48 | 4 |  |  |  |  | 6 | $out .= " # TODO & SKIP"; | 
| 49 | 4 | 100 |  |  |  | 15 | $out .= " $todo" if length $todo; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  | elsif (defined $todo) { | 
| 52 | 10 |  |  |  |  | 19 | $out .= " # TODO"; | 
| 53 | 10 | 100 |  |  |  | 42 | $out .= " $todo" if length $todo; | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  | elsif (defined $skip) { | 
| 56 | 7 |  |  |  |  | 10 | $out .= " # skip"; | 
| 57 | 7 | 100 |  |  |  | 23 | $out .= " $skip" if length $skip; | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 2934 |  |  |  |  | 9081 | my @out = [OUT_STD, "$out\n"]; | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 2934 | 100 | 100 |  |  | 8380 | if ($self->{+DIAG} && @{$self->{+DIAG}}) { | 
|  | 21 |  |  |  |  | 95 |  | 
| 63 | 19 | 100 |  |  |  | 60 | my $diag_handle = $debug->no_diag ? OUT_TODO : OUT_ERR; | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 19 |  |  |  |  | 35 | for my $diag (@{$self->{+DIAG}}) { | 
|  | 19 |  |  |  |  | 47 |  | 
| 66 | 28 |  |  |  |  | 56 | chomp(my $msg = $diag); | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 28 | 100 |  |  |  | 107 | $msg = "# $msg" unless $msg =~ m/^\n/; | 
| 69 | 28 |  |  |  |  | 77 | $msg =~ s/\n/\n# /g; | 
| 70 | 28 |  |  |  |  | 112 | push @out => [$diag_handle, "$msg\n"]; | 
| 71 |  |  |  |  |  |  | } | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 | 2934 |  |  |  |  | 9509 | return @out; | 
| 75 |  |  |  |  |  |  | } | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | sub default_diag { | 
| 78 | 199 |  |  | 199 | 1 | 307 | my $self = shift; | 
| 79 |  |  |  |  |  |  |  | 
| 80 | 199 | 100 |  |  |  | 552 | return if $self->{+PASS}; | 
| 81 |  |  |  |  |  |  |  | 
| 82 | 198 |  |  |  |  | 335 | my $name  = $self->{+NAME}; | 
| 83 | 198 |  |  |  |  | 315 | my $dbg   = $self->{+DEBUG}; | 
| 84 | 198 |  |  |  |  | 314 | my $pass  = $self->{+PASS}; | 
| 85 | 198 |  |  |  |  | 685 | my $todo  = defined $dbg->todo; | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 198 | 100 |  |  |  | 930 | my $msg = $todo ? "Failed (TODO)" : "Failed"; | 
| 88 | 198 | 100 | 100 |  |  | 1136 | my $prefix = $ENV{HARNESS_ACTIVE} && !$ENV{HARNESS_IS_VERBOSE} ? "\n" : ""; | 
| 89 |  |  |  |  |  |  |  | 
| 90 | 198 |  |  |  |  | 670 | my $trace = $dbg->trace; | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 198 | 100 |  |  |  | 473 | if (defined $name) { | 
| 93 | 157 |  |  |  |  | 691 | $msg = qq[$prefix$msg test '$name'\n$trace.]; | 
| 94 |  |  |  |  |  |  | } | 
| 95 |  |  |  |  |  |  | else { | 
| 96 | 41 |  |  |  |  | 112 | $msg = qq[$prefix$msg test $trace.]; | 
| 97 |  |  |  |  |  |  | } | 
| 98 |  |  |  |  |  |  |  | 
| 99 | 198 |  |  |  |  | 812 | return $msg; | 
| 100 |  |  |  |  |  |  | } | 
| 101 |  |  |  |  |  |  |  | 
| 102 | 3185 |  |  | 3185 | 1 | 11342 | sub update_state { $_[1]->bump($_[0]->{+EFFECTIVE_PASS}) } | 
| 103 |  |  |  |  |  |  |  | 
| 104 | 1765 |  |  | 1765 | 1 | 10645 | sub causes_fail { !$_[0]->{+EFFECTIVE_PASS} } | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | 1; | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | __END__ |