@@ -4,15 +4,26 @@ use Test;
4
4
5
5
proto sub tap_ok (|) is export { * }
6
6
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
+ ) {
10
18
ok $ s ~~ Supply , " { $ s .^ name } appears to be doing Supply" ;
11
19
is $ s . live, $ live , " Supply appears to { ' NOT ' unless $ live } be live" ;
12
20
13
21
my @ res ;
14
22
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
+ );
16
27
after-tap() if & after-tap ;
17
28
18
29
$ timeout *= 10 ;
@@ -35,7 +46,17 @@ Test::Tap - Extra utility code for testing Supply
35
46
36
47
tap_ok( $supply, [<a b c>], "comment" );
37
48
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
+ );
39
60
40
61
= head1 DESCRIPTION
41
62
@@ -59,10 +80,20 @@ Takes optional named parameters:
59
80
60
81
= over 4
61
82
62
- = item :sort
83
+ = item :live
63
84
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.
66
97
67
98
= item :after-tap( {...} )
68
99
@@ -73,10 +104,10 @@ By default, does B<not> execute any code.
73
104
74
105
Optional timeout specification: defaults to B < 5 > (seconds).
75
106
76
- = item :live
107
+ = item :sort
77
108
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 .
80
111
81
112
=back
82
113
0 commit comments