Skip to content

Commit 8ea1475

Browse files
committed
Added ":more" and ":done" feature to tap_ok
Mostly useful for debugging tests, I would think.
1 parent 3fa50a0 commit 8ea1475

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

packages/Test/Tap.pm

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@ use Test;
44

55
proto sub tap_ok(|) is export { * }
66

7-
multi sub tap_ok
8-
($s,$expected,$text,:$sort,:&after-tap,:$timeout is copy = 5,:$live = False)
9-
{
7+
multi sub tap_ok (
8+
$s,
9+
$expected,
10+
$text,
11+
:$live = False,
12+
:&more,
13+
:&done,
14+
:&after-tap,
15+
:$timeout is copy = 5,
16+
:$sort,
17+
) {
1018
ok $s ~~ Supply, "{$s.^name} appears to be doing Supply";
1119
is $s.live, $live, "Supply appears to {'NOT ' unless $live}be live";
1220

1321
my @res;
1422
my $done;
15-
$s.tap({ @res.push($_) }, :done( {$done = True} ));
23+
$s.tap(
24+
{ more() if &more; @res.push($_) },
25+
:done( { done() if &done; $done = True } ),
26+
);
1627
after-tap() if &after-tap;
1728

1829
$timeout *= 10;
@@ -35,7 +46,17 @@ Test::Tap - Extra utility code for testing Supply
3546
3647
tap_ok( $supply, [<a b c>], "comment" );
3748
38-
tap_ok($supply,[<a b c>],"text",:sort,:after-tap({...}),:timeout(50),:live);
49+
tap_ok(
50+
$supply,
51+
[<a b c>],
52+
"text",
53+
:live,
54+
:more( { ... } ),
55+
:done( { ... } ),
56+
:after-tap( { ... } ),
57+
:timeout(50),
58+
:sort,
59+
);
3960
4061
=head1 DESCRIPTION
4162
@@ -59,10 +80,20 @@ Takes optional named parameters:
5980
6081
=over 4
6182
62-
=item :sort
83+
=item :live
6384
64-
Boolean indicating whether to sort the values provided by the supply before
65-
checking it against the desired result. Default is no sorting.
85+
Optional indication of the value C<Supply.live> is supposed to return. By
86+
default, the C<Supply> is expected to be C<on demand> (as in B<not> live).
87+
88+
=item :more( {...} )
89+
90+
Optional code to be executed whenever a value is received ("more"d) on the tap.
91+
By default, does B<not> execute any code.
92+
93+
=item :done( {...} )
94+
95+
Optional code to be executed whenever the supply indicates it is "done".
96+
By default, does B<not> execute any code.
6697
6798
=item :after-tap( {...} )
6899
@@ -73,10 +104,10 @@ By default, does B<not> execute any code.
73104
74105
Optional timeout specification: defaults to B<5> (seconds).
75106
76-
=item :live
107+
=item :sort
77108
78-
Optional indication of the value C<Supply.live> is supposed to return. By
79-
default, the C<Supply> is expected to be C<on demand> (as in B<not> live).
109+
Boolean indicating whether to sort the values provided by the supply before
110+
checking it against the desired result. Default is no sorting.
80111
81112
=back
82113

0 commit comments

Comments
 (0)