Skip to content

Commit

Permalink
Step #2 of deprecating Supply.for for from-list
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Mar 12, 2015
1 parent bf6bb04 commit 9c90d8a
Show file tree
Hide file tree
Showing 28 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion S17-supply/act.t
Expand Up @@ -11,7 +11,7 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {

{
my @seen;
my $tap = Supply.for(1..10).act( { @seen.push($_) } );
my $tap = Supply.from-list(1..10).act( { @seen.push($_) } );
isa_ok $tap, Tap, 'we got a Tap';
sleep .1 until @seen == 10;
is_deeply @seen, [1..10], 'we got all of the values';
Expand Down
4 changes: 2 additions & 2 deletions S17-supply/batch.t
Expand Up @@ -11,7 +11,7 @@ dies_ok { Supply.batch(1000) }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..14).batch(:elems(5)),
tap_ok Supply.from-list(1..14).batch(:elems(5)),
[[1..5],[6..10],[11..14]],
"we can batch by number of elements";

Expand Down Expand Up @@ -56,7 +56,7 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
}

{
my $f = Supply.for(1..10);
my $f = Supply.from-list(1..10);
my $b = $f.batch(:elems(1)),
ok $f === $b, "batch by 1 is a noop";
tap_ok $b, [1..10], "noop batch";
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/delayed.t
Expand Up @@ -45,7 +45,7 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
}

{
my $for = Supply.for(1..10);
my $for = Supply.from-list(1..10);
my $delay = $for.delayed(0);
ok $for === $delay, "delaying by 0 is a noop";
tap_ok $delay, [1..10], "noop delay";
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/do.t
Expand Up @@ -13,7 +13,7 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {

{
my $seen;
tap_ok Supply.for(1..10).do( {$seen++} ),
tap_ok Supply.from-list(1..10).do( {$seen++} ),
[1..10], ".do worked";
is $seen, 10, "did the side effect work";
}
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/elems.t
Expand Up @@ -11,7 +11,7 @@ dies_ok { Supply.elems }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(42..51).elems, [1..10], "just tracing elems works";
tap_ok Supply.from-list(42..51).elems, [1..10], "just tracing elems works";

{
my $s = Supply.new;
Expand Down
2 changes: 1 addition & 1 deletion S17-supply/flat.t
Expand Up @@ -11,7 +11,7 @@ dies_ok { Supply.flat }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for( [1,2],[3,4,5] ).flat,
tap_ok Supply.from-list( [1,2],[3,4,5] ).flat,
[1..5], "On demand publish with flat";

my $s = Supply.new;
Expand Down
4 changes: 2 additions & 2 deletions S17-supply/from-list.t
Expand Up @@ -6,13 +6,13 @@ use Test::Tap;

plan 13;

dies_ok { Supply.new.for(1..10) }, 'can not be called as an instance method';
dies_ok { Supply.new.from-list(1..10) }, 'can not be called as an instance method';

for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

{
my $s = Supply.for(1..10);
my $s = Supply.from-list(1..10);
tap_ok $s, [1..10], "On demand publish worked";
tap_ok $s, [1..10], "Second tap gets all the values";

Expand Down
4 changes: 2 additions & 2 deletions S17-supply/grab.t
Expand Up @@ -11,6 +11,6 @@ dies_ok { Supply.grab }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..10).grab( {.reverse} ), [10...1], "we can reverse";
tap_ok Supply.for(1..10).grab( {[min] $_} ), [1], "we can find the min";
tap_ok Supply.from-list(1..10).grab( {.reverse} ), [10...1], "we can reverse";
tap_ok Supply.from-list(1..10).grab( {[min] $_} ), [1], "we can find the min";
}
6 changes: 3 additions & 3 deletions S17-supply/grep.t
Expand Up @@ -11,15 +11,15 @@ dies_ok { Supply.grep({...}) }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..10).grep( * > 5 ),
tap_ok Supply.from-list(1..10).grep( * > 5 ),
[6,7,8,9,10],
"grepping taps with a Callable works";

tap_ok Supply.for(1..10,"a".."z").grep(Int),
tap_ok Supply.from-list(1..10,"a".."z").grep(Int),
[1..10],
"grepping taps with a Type works";

tap_ok Supply.for("a".."z").grep(/<[a..e]>/),
tap_ok Supply.from-list("a".."z").grep(/<[a..e]>/),
["a".."e"],
"grepping taps with a Regex works";
}
6 changes: 3 additions & 3 deletions S17-supply/last.t
Expand Up @@ -14,7 +14,7 @@ dies_ok { Supply.new.last("foo") }, 'cannot have "foo" last';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..10).last, [10], "the last one works";
tap_ok Supply.for(1..10).last(5), [6..10], "the last five works";
tap_ok Supply.for(1..10).last(15), [1..10], "the last 15 works";
tap_ok Supply.from-list(1..10).last, [10], "the last one works";
tap_ok Supply.from-list(1..10).last(5), [6..10], "the last five works";
tap_ok Supply.from-list(1..10).last(15), [1..10], "the last 15 works";
}
16 changes: 8 additions & 8 deletions S17-supply/lines.t
Expand Up @@ -15,31 +15,31 @@ dies_ok { Supply.lines }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for( @simple.map: * ~ "\n" ).lines,
tap_ok Supply.from-list( @simple.map: * ~ "\n" ).lines,
@simple,
"handle a simple list of lines with LF";
tap_ok Supply.for( @original = @simple.map: * ~ "\n" ).lines(:!chomp),
tap_ok Supply.from-list( @original = @simple.map: * ~ "\n" ).lines(:!chomp),
@original,
"handle a simple list of lines with LF without chomping";

tap_ok Supply.for( @simple.map: * ~ "\r" ).lines,
tap_ok Supply.from-list( @simple.map: * ~ "\r" ).lines,
@simple,
"handle a simple list of lines with CR";
tap_ok Supply.for( @original = @simple.map: * ~ "\r" ).lines(:!chomp),
tap_ok Supply.from-list( @original = @simple.map: * ~ "\r" ).lines(:!chomp),
@original,
"handle a simple list of lines with CR without chomping";

tap_ok Supply.for( @simple.map: * ~ "\r\n" ).lines,
tap_ok Supply.from-list( @simple.map: * ~ "\r\n" ).lines,
@simple,
"handle a simple list of lines with CRLF";
tap_ok Supply.for( @original = @simple.map: * ~ "\r\n" ).lines(:!chomp),
tap_ok Supply.from-list( @original = @simple.map: * ~ "\r\n" ).lines(:!chomp),
@original,
"handle a simple list of lines with CRLF without chomping";

tap_ok Supply.for( @simple.map: * ~ @endings.pick ).lines,
tap_ok Supply.from-list( @simple.map: * ~ @endings.pick ).lines,
@simple,
"handle a simple list of lines with mixed line ending";
tap_ok Supply.for(@original= @simple.map: * ~ @endings.pick).lines(:!chomp),
tap_ok Supply.from-list(@original= @simple.map: * ~ @endings.pick).lines(:!chomp),
@original,
"handle a simple list of lines with mixed line ending w/o chomping";

Expand Down
4 changes: 2 additions & 2 deletions S17-supply/list.t
Expand Up @@ -12,9 +12,9 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
#?rakudo.jvm skip "hangs"
{
my @a;
for Supply.for(2..6).list { @a.push($_) };
for Supply.from-list(2..6).list { @a.push($_) };
is_deeply @a, [2..6], "Supply.list works in for";
my @b = Supply.for(42..50).list;
my @b = Supply.from-list(42..50).list;
is_deeply @b, [42..50], "Supply.list can be stored in array";
}
}
8 changes: 4 additions & 4 deletions S17-supply/map.t
Expand Up @@ -11,17 +11,17 @@ dies_ok { Supply.map({...}) }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for( (1..5).map( {[$_]} ) ),
tap_ok Supply.from-list( (1..5).map( {[$_]} ) ),
[[1],[2],[3],[4],[5]], "On demand publish with arrays";

tap_ok Supply.for( [1,2],[3,4,5] ).map( {.flat} ),
tap_ok Supply.from-list( [1,2],[3,4,5] ).map( {.flat} ),
[1..5], "On demand publish with flattened arrays";

tap_ok Supply.for(1..10).map( * * 5 ),
tap_ok Supply.from-list(1..10).map( * * 5 ),
[5,10,15,20,25,30,35,40,45,50],
"mapping tap with single values works";

tap_ok Supply.for(1..10).map( { $_ xx 2 } ),
tap_ok Supply.from-list(1..10).map( { $_ xx 2 } ),
[1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10],
"mapping tap with multiple values works";
}
8 changes: 4 additions & 4 deletions S17-supply/max.t
Expand Up @@ -12,12 +12,12 @@ dies_ok { Supply.new.max(23) }, 'must be code if specified';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..10).max, [1..10],
tap_ok Supply.from-list(1..10).max, [1..10],
"ascending max works";
tap_ok Supply.for(10...1).max, [10],
tap_ok Supply.from-list(10...1).max, [10],
"descending max works";
tap_ok Supply.for("a".."e","A".."E").max(*.uc), [<a b c d e>],
tap_ok Supply.from-list("a".."e","A".."E").max(*.uc), [<a b c d e>],
"ascending alpha works";
tap_ok Supply.for("E"..."A","e".."a").max(*.lc), ["E"],
tap_ok Supply.from-list("E"..."A","e".."a").max(*.lc), ["E"],
"descending alpha works";
}
4 changes: 2 additions & 2 deletions S17-supply/merge.t
Expand Up @@ -27,12 +27,12 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
}

tap_ok Supply.merge(
Supply.for(1..5), Supply.for(6..10), Supply.for(11..15)
Supply.from-list(1..5), Supply.from-list(6..10), Supply.from-list(11..15)
),
[1..15], "merging 3 supplies works", :sort;

{
my $s = Supply.for(1..10);
my $s = Supply.from-list(1..10);
my $m = Supply.merge($s);
ok $s === $m, "merging one supply is a noop";
tap_ok $m, [1..10], "noop merge";
Expand Down
8 changes: 4 additions & 4 deletions S17-supply/min.t
Expand Up @@ -12,12 +12,12 @@ dies_ok { Supply.new.min(23) }, 'must be code if specified';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..10).min, [1],
tap_ok Supply.from-list(1..10).min, [1],
"ascending min works";
tap_ok Supply.for(10...1).min, [10...1],
tap_ok Supply.from-list(10...1).min, [10...1],
"descending min works";
tap_ok Supply.for("a".."e","A".."E").min(*.uc), ["a"],
tap_ok Supply.from-list("a".."e","A".."E").min(*.uc), ["a"],
"ascending alpha works";
tap_ok Supply.for("E"..."A","e".."a").min(*.lc), [<E D C B A>],
tap_ok Supply.from-list("E"..."A","e".."a").min(*.lc), [<E D C B A>],
"descending alpha works";
}
8 changes: 4 additions & 4 deletions S17-supply/minmax.t
Expand Up @@ -12,14 +12,14 @@ dies_ok { Supply.new.minmax(23) }, 'must be code if specified';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..5).minmax, [(1..1),(1..2),(1..3),(1..4),(1..5)],
tap_ok Supply.from-list(1..5).minmax, [(1..1),(1..2),(1..3),(1..4),(1..5)],
"ascending minmax works";
tap_ok Supply.for(5...1).minmax, [(5..5),(4..5),(3..5),(2..5),(1..5)],
tap_ok Supply.from-list(5...1).minmax, [(5..5),(4..5),(3..5),(2..5),(1..5)],
"descending minmax works";
tap_ok Supply.for("a".."e","A".."E").minmax(*.uc),
tap_ok Supply.from-list("a".."e","A".."E").minmax(*.uc),
[("a".."a"),("a".."b"),("a".."c"),("a".."d"),("a".."e")],
"ascending alpha works";
tap_ok Supply.for("E"..."A","e".."a").minmax(*.lc),
tap_ok Supply.from-list("E"..."A","e".."a").minmax(*.lc),
[("E".."E"),("D".."E"),("C".."E"),("B".."E"),("A".."E")],
"descending alpha works";
}
14 changes: 7 additions & 7 deletions S17-supply/on.t
Expand Up @@ -10,7 +10,7 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

{
my $s1 = Supply.for(1..10);
my $s1 = Supply.from-list(1..10);
my $on = on -> $res {
$s1 => sub ($val) {
$res.emit($val);
Expand All @@ -20,8 +20,8 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
}

{
my $s1 = Supply.for("a".."j");
my $s2 = Supply.for(1..10);
my $s1 = Supply.from-list("a".."j");
my $s2 = Supply.from-list(1..10);
my $on = on -> $res {
my @a1;
my @a2;
Expand All @@ -44,8 +44,8 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
}

{
my $a = Supply.for("a".."e");
my $b = Supply.for("f".."k");
my $a = Supply.from-list("a".."e");
my $b = Supply.from-list("f".."k");
my $on = on -> $res {
my @values = ([],[]);
($a,$b) => sub ($val,$index) {
Expand All @@ -61,7 +61,7 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
}

{
my @s=(Supply.for("a".."e"),Supply.for("f".."k"),Supply.for("l".."p"));
my @s=(Supply.from-list("a".."e"),Supply.from-list("f".."k"),Supply.from-list("l".."p"));
my $on = on -> $res {
my @values = ([] xx +@s);
my &infix:<op> = &[,];
Expand All @@ -78,7 +78,7 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
}

{
my @s = ( Supply.for("a".."e"), Supply.for("f".."k") );
my @s = ( Supply.from-list("a".."e"), Supply.from-list("f".."k") );
my @seen;
my $on = on -> $res {
my $done = 0;
Expand Down
6 changes: 3 additions & 3 deletions S17-supply/reduce.t
Expand Up @@ -12,11 +12,11 @@ dies_ok { Supply.new.reduce(23) }, 'must be code if specified';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..5).reduce( {$^a + $^b} ), [1,3,6,10,15],
tap_ok Supply.from-list(1..5).reduce( {$^a + $^b} ), [1,3,6,10,15],
"simple reduce works";
tap_ok Supply.for(42).reduce( {$^a * $^b} ), [42],
tap_ok Supply.from-list(42).reduce( {$^a * $^b} ), [42],
"minimal reduce works";
tap_ok Supply.for("a".."e").reduce(&infix:<~>),
tap_ok Supply.from-list("a".."e").reduce(&infix:<~>),
[<a ab abc abcd abcde>],
"reducing with concatenate works";

Expand Down
2 changes: 1 addition & 1 deletion S17-supply/reverse.t
Expand Up @@ -11,5 +11,5 @@ dies_ok { Supply.reverse }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..10).reverse, [10...1], "we can reverse";
tap_ok Supply.from-list(1..10).reverse, [10...1], "we can reverse";
}
6 changes: 3 additions & 3 deletions S17-supply/rotor.t
Expand Up @@ -11,16 +11,16 @@ dies_ok { Supply.rotor }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..5).rotor,
tap_ok Supply.from-list(1..5).rotor,
[[1,2],[2,3],[3,4],[4,5],[5]],
"we can rotor";

tap_ok Supply.for(1..5).rotor(3,2),
tap_ok Supply.from-list(1..5).rotor(3,2),
[[1,2,3],[2,3,4],[3,4,5],[4,5]],
"we can rotor by number of elements and overlap";

{
my $for = Supply.for(1..10);
my $for = Supply.from-list(1..10);
my $rotor = $for.rotor(1,0);
ok $for === $rotor, "rotoring by 1/0 is a noop";
tap_ok $rotor, [1..10], "noop rotor";
Expand Down
6 changes: 3 additions & 3 deletions S17-supply/sort.t
Expand Up @@ -11,9 +11,9 @@ dies_ok { Supply.sort }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(10...1).sort, [1..10], "we can sort numbers";
tap_ok Supply.for("z"..."a").sort, ["a" .. "z"], "we can sort strings";
tap_ok Supply.for("a".."d", "A" .. "D").sort( {
tap_ok Supply.from-list(10...1).sort, [1..10], "we can sort numbers";
tap_ok Supply.from-list("z"..."a").sort, ["a" .. "z"], "we can sort strings";
tap_ok Supply.from-list("a".."d", "A" .. "D").sort( {
$^a.lc cmp $^b.lc || $^b cmp $^a
} ), [<a A b B c C d D>], "we can sort in special ways";
}
10 changes: 5 additions & 5 deletions S17-supply/squish.t
Expand Up @@ -11,23 +11,23 @@ dies_ok { Supply.squish }, 'can not be called as a class method';
for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
diag "**** scheduling with {$*SCHEDULER.WHAT.perl}";

tap_ok Supply.for(1..10,1..10).squish,
tap_ok Supply.from-list(1..10,1..10).squish,
[1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10],
"squish tap with 2 ranges works";

tap_ok Supply.for(1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10).squish,
tap_ok Supply.from-list(1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10).squish,
[1,2,3,4,5,6,7,8,9,10],
"squish tap with doubling range works";

tap_ok Supply.for(1..10).squish(:as(* div 2)),
tap_ok Supply.from-list(1..10).squish(:as(* div 2)),
[1,2,4,6,8,10],
"squish with as tap works";

tap_ok Supply.for(<a A B b c C A>).squish( :with( {$^a.lc eq $^b.lc} ) ),
tap_ok Supply.from-list(<a A B b c C A>).squish( :with( {$^a.lc eq $^b.lc} ) ),
[<a B c A>],
"squish with with tap works";

tap_ok Supply.for(<a AA B bb cc C AA>).squish(
tap_ok Supply.from-list(<a AA B bb cc C AA>).squish(
:as( *.substr(0,1) ), :with( {$^a.lc eq $^b.lc} )
),
[<a B cc AA>],
Expand Down

0 comments on commit 9c90d8a

Please sign in to comment.