| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Test::Clear; | 
| 2 | 4 |  |  | 4 |  | 59414 | use 5.008005; | 
|  | 4 |  |  |  |  | 46 |  | 
|  | 4 |  |  |  |  | 148 |  | 
| 3 | 4 |  |  | 4 |  | 19 | use strict; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 123 |  | 
| 4 | 4 |  |  | 4 |  | 25 | use warnings; | 
|  | 4 |  |  |  |  | 6 |  | 
|  | 4 |  |  |  |  | 118 |  | 
| 5 | 4 |  |  | 4 |  | 2066 | use parent 'Exporter'; | 
|  | 4 |  |  |  |  | 1216 |  | 
|  | 4 |  |  |  |  | 20 |  | 
| 6 | 4 |  |  | 4 |  | 207 | use Test::More; | 
|  | 4 |  |  |  |  | 7 |  | 
|  | 4 |  |  |  |  | 23 |  | 
| 7 | 4 |  |  | 4 |  | 967 | use Test::Builder; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 85 |  | 
| 8 | 4 |  |  | 4 |  | 2859 | use Data::Dumper; | 
|  | 4 |  |  |  |  | 28632 |  | 
|  | 4 |  |  |  |  | 259 |  | 
| 9 | 4 |  |  | 4 |  | 1731 | use Scope::Guard; | 
|  | 4 |  |  |  |  | 1381 |  | 
|  | 4 |  |  |  |  | 1662 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | our $VERSION = "0.04"; | 
| 12 |  |  |  |  |  |  | our @EXPORT = qw(case todo_scope todo_note); | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | sub dumper { | 
| 15 | 4 |  |  | 4 | 0 | 5 | my $value = shift; | 
| 16 | 4 | 50 |  |  |  | 8 | if ( not defined $value ) { | 
| 17 | 0 |  |  |  |  | 0 | return 'undef'; | 
| 18 |  |  |  |  |  |  | } | 
| 19 | 4 | 100 | 66 |  |  | 17 | if ( defined $value && ref($value) ) { | 
| 20 | 1 |  |  |  |  | 2 | local $Data::Dumper::Terse = 1; | 
| 21 | 1 |  |  |  |  | 2 | local $Data::Dumper::Indent = 0; | 
| 22 | 1 |  |  |  |  | 2 | local $Data::Dumper::Sortkeys = 1; | 
| 23 | 1 |  |  |  |  | 5 | return Data::Dumper::Dumper($value); | 
| 24 |  |  |  |  |  |  | } | 
| 25 | 3 |  |  |  |  | 8 | return $value; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub case { | 
| 29 | 4 |  |  | 4 | 1 | 6018 | my ($caption, $dataset, $testcode, $opts) = @_; | 
| 30 | 4 | 100 |  |  |  | 11 | $dataset = (ref $dataset eq 'CODE') ? $dataset->(): $dataset; | 
| 31 | 4 |  |  |  |  | 13 | $caption = embeded($caption, $dataset); | 
| 32 | 4 |  |  |  |  | 92 | my $tb = Test::More->builder; | 
| 33 | 4 |  |  |  |  | 39 | return $tb->subtest($caption, $testcode, $dataset); | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub embeded { | 
| 37 | 4 |  |  | 4 | 0 | 5 | my ($caption, $dataset) = @_; | 
| 38 |  |  |  |  |  |  | return | 
| 39 | 8 | 100 |  |  |  | 31 | join '', | 
| 40 |  |  |  |  |  |  | map { | 
| 41 | 8 | 50 |  |  |  | 28 | /^\{(.+?)\}$/ | 
| 42 |  |  |  |  |  |  | ? dumper($dataset->{$1}) | 
| 43 |  |  |  |  |  |  | : $_ | 
| 44 |  |  |  |  |  |  | } | 
| 45 | 4 |  |  |  |  | 25 | grep { defined && length } | 
| 46 |  |  |  |  |  |  | split /(\{.+?\})/, $caption; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | sub todo_scope { | 
| 50 | 1 |  |  | 1 | 1 | 1042 | my ($reason) = @_; | 
| 51 | 1 |  |  |  |  | 5 | my $tb = Test::More->builder; | 
| 52 | 1 |  |  |  |  | 18 | $tb->todo_start($reason); | 
| 53 | 1 |  |  | 1 |  | 76 | Scope::Guard->new(sub { $tb->todo_end }); | 
|  | 1 |  |  |  |  | 449 |  | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | sub todo_note { | 
| 57 | 2 |  |  | 2 | 0 | 17 | my ($caption, $reason) = @_; | 
| 58 | 2 |  | 100 |  |  | 8 | $reason ||= ''; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 2 |  |  |  |  | 15 | my (undef, $file, $line) = caller(0); | 
| 61 | 2 |  |  |  |  | 6 | $reason .= " [ $file line $line ]\n"; | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 2 |  |  |  |  | 14 | my $tb = Test::More->builder; | 
| 64 | 2 |  |  |  |  | 26 | $tb->todo_start($reason); | 
| 65 | 2 |  |  |  |  | 73 | pass $caption; | 
| 66 | 2 |  |  |  |  | 406 | $tb->todo_end; | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | 1; | 
| 70 |  |  |  |  |  |  | __END__ |