Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add tests for on demand/live state of Supply
  • Loading branch information
lizmat committed Apr 28, 2014
1 parent 0381e1d commit 5967271
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion S17-supply/batch.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 28;
plan 36;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/do.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 10;
plan 12;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/flat.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 8;
plan 10;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/for.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 34;
plan 44;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/grep.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 8;
plan 10;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/map.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 26;
plan 34;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/merge.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 22;
plan 28;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/on.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 32;
plan 42;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/rotor.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 22;
plan 28;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/squish.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 32;
plan 42;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/uniq.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 50;
plan 66;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/zip.t
Expand Up @@ -4,7 +4,7 @@ use lib 't/spec/packages';
use Test;
use Test::Tap;

plan 22;
plan 28;

for (ThreadPoolScheduler, CurrentThreadScheduler) {
$*SCHEDULER = .new;
Expand Down
17 changes: 13 additions & 4 deletions packages/Test/Tap.pm
Expand Up @@ -4,8 +4,11 @@ use Test;

proto sub tap_ok(|) is export { * }

multi sub tap_ok ($s,$expected,$text,:$sort,:&after-tap,:$timeout is copy = 5) {
multi sub tap_ok
($s,$expected,$text,:$sort,:&after-tap,:$timeout is copy = 5,:$live = False)
{
ok $s ~~ Supply, "{$s.^name} appears to be doing Supply";
is $s.live, $live, "Supply appears to {'NOT' unless $live} be live";

my @res;
my $done;
Expand All @@ -32,7 +35,7 @@ Test::Tap - Extra utility code for testing Supply
tap_ok( $supply, [<a b c>], "comment" );
tap_ok( $supply,[<a b c>],"comment",:sort,:after-tap( {...} ),:timeout(50) );
tap_ok($supply,[<a b c>],"text",:sort,:after-tap({...}),:timeout(50),:live);
=head1 DESCRIPTION
Expand All @@ -43,9 +46,10 @@ This module is for Supply test code.
=head2 tap_ok( $s, [$result], "comment" )
Takes 3 positional parameters: the C<Supply> to be tested, an array with the
expected values, and a comment to describe the test. Good for B<3> tests.
expected values, and a comment to describe the test. Good for B<4> tests.
First tests whether the first positional is a Supply. Then attempts to put a
First tests whether the first positional is a Supply. Then checks whether
the Supply is live or on demand with what is expected. Then attempts to put a
C<.tap> on the Supply. Then runs any code specified to be run after the tap.
Then waits for the Supply to be C<done>, or until the timeout has passed.
Emits a fail if the timeout has passed. Then sorts the values as received from
Expand All @@ -69,6 +73,11 @@ By default, does B<not> execute any code.
Optional timeout specification: defaults to B<5> (seconds).
=item :live
Optional indication of the value C<Supply.live> is supposed to return. By
default, the C<Supply> is expected to be C<on demand> (as in B<not> live).
=back
=end pod
Expand Down

0 comments on commit 5967271

Please sign in to comment.