| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DDG::Test::Goodie; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:DDG'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Adds keywords to easily test Goodie plugins. |
|
4
|
|
|
|
|
|
|
$DDG::Test::Goodie::VERSION = '1016'; |
|
5
|
4
|
|
|
4
|
|
47552
|
use strict; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
89
|
|
|
6
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
|
4
|
|
|
|
|
3
|
|
|
|
4
|
|
|
|
|
74
|
|
|
7
|
4
|
|
|
4
|
|
10
|
use Carp; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
163
|
|
|
8
|
4
|
|
|
4
|
|
19
|
use Test::More; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
18
|
|
|
9
|
4
|
|
|
4
|
|
2566
|
use Test::Deep; |
|
|
4
|
|
|
|
|
30563
|
|
|
|
4
|
|
|
|
|
23
|
|
|
10
|
4
|
|
|
4
|
|
2125
|
use DDG::Test::Block; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
17
|
|
|
11
|
4
|
|
|
4
|
|
942
|
use DDG::ZeroClickInfo; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
101
|
|
|
12
|
4
|
|
|
4
|
|
17
|
use Package::Stash; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
1297
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
binmode STDOUT, ':utf8'; |
|
15
|
|
|
|
|
|
|
binmode Test::More->builder->output, ':utf8'; |
|
16
|
|
|
|
|
|
|
binmode Test::More->builder->failure_output, ':utf8'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub import { |
|
20
|
4
|
|
|
4
|
|
28
|
my ( $class, %params ) = @_; |
|
21
|
4
|
|
|
|
|
6
|
my $target = caller; |
|
22
|
4
|
|
|
|
|
34
|
my $stash = Package::Stash->new($target); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
5
|
my %zci_params; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$stash->add_symbol('&test_zci', sub { |
|
28
|
8
|
|
|
8
|
|
4460
|
my $answer = shift; |
|
29
|
|
|
|
|
|
|
ref $_[0] eq 'HASH' ? |
|
30
|
8
|
50
|
|
|
|
113
|
DDG::ZeroClickInfo->new(%zci_params, %{$_[0]}, answer => $answer ) : |
|
|
0
|
|
|
|
|
0
|
|
|
31
|
|
|
|
|
|
|
DDG::ZeroClickInfo->new(%zci_params, @_, answer => $answer ) |
|
32
|
4
|
|
|
|
|
53
|
}); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$stash->add_symbol('&zci', sub { |
|
36
|
2
|
50
|
|
2
|
|
13
|
if (ref $_[0] eq 'HASH') { |
|
37
|
0
|
|
|
|
|
0
|
for (keys %{$_[0]}) { |
|
|
0
|
|
|
|
|
0
|
|
|
38
|
0
|
|
|
|
|
0
|
$zci_params{$_} = $_[0]->{$_}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} else { |
|
41
|
2
|
|
|
|
|
7
|
while (@_) { |
|
42
|
2
|
|
|
|
|
3
|
my $key = shift; |
|
43
|
2
|
|
|
|
|
4
|
my $value = shift; |
|
44
|
2
|
|
|
|
|
9
|
$zci_params{$key} = $value; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
4
|
|
|
|
|
22
|
}); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$stash->add_symbol('&ddg_goodie_test', sub { block_test(sub { |
|
51
|
8
|
|
|
8
|
|
10
|
my ($query, $answer, $zci) = @_; |
|
52
|
|
|
|
|
|
|
subtest "Query: $query" => sub { |
|
53
|
8
|
50
|
|
|
|
3849
|
if ($answer) { |
|
54
|
8
|
|
|
|
|
31
|
$zci->{caller} = $answer->caller; # TODO: Review all this cheating; seriously. |
|
55
|
8
|
|
|
|
|
25
|
cmp_deeply($answer,$zci,'Deep: full ZCI object'); |
|
56
|
|
|
|
|
|
|
} else { |
|
57
|
0
|
0
|
|
|
|
|
fail('Expected result but dont get one on '.$query) unless defined $answer; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
8
|
|
|
|
|
57
|
}; |
|
60
|
6
|
|
|
6
|
|
74
|
},@_) |
|
61
|
4
|
|
|
|
|
101
|
}); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |