Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for snip functionality #814

Merged
merged 1 commit into from Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions S17-supply/snip.t
@@ -0,0 +1,26 @@
use v6.e.PREVIEW;
use Test;
use lib $?FILE.IO.parent(2).add("packages/Test-Helpers");
use Test::Tap;

plan 7;

dies-ok { Supply.snip(1000) }, 'can not be called as a class method';

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

tap-ok Supply.from-list(1..14).snip(*>9),
[(1,2,3,4,5,6,7,8,9),(10,11,12,13,14)],
"we can snip with a single test";

tap-ok Supply.from-list(1..14).snip(*>9, *>11),
[(1,2,3,4,5,6,7,8,9),(10,11),(12,13,14)],
"we can snip with two tests";

tap-ok Supply.from-list("a","b","c",1,2,3).snip(Int),
[("a","b","c"),(1,2,3)],
"we can snip with a type object";
}

# vim: expandtab shiftwidth=4
34 changes: 34 additions & 0 deletions S32-list/snip.t
@@ -0,0 +1,34 @@
use v6.e.PREVIEW;

use Test;

plan 6;

my @a = 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4;

is-deeply snip(* < 10, 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4),
((2,2,2,5,5,7), (13,9,6,2,20,4)),
'sub snip with a single Callable and a slurpy list';

is-deeply snip(* < 10, @a),
((2,2,2,5,5,7), (13,9,6,2,20,4)),
'sub snip with a single Callable and an array';

is-deeply @a.snip(* < 10),
((2,2,2,5,5,7), (13,9,6,2,20,4)),
'snip method with a single Callable and an array';

is-deeply snip( (* < 10, * < 20), 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4),
((2,2,2,5,5,7),(13,9,6,2),(20,4)),
'sub snip with two Callables with a slurpy list';

is-deeply snip( (* < 10, * < 20), @a),
((2,2,2,5,5,7),(13,9,6,2),(20,4)),
'sub snip with two Callables and an array';

is-deeply snip( Int, 2, 2, 2, 5, 5, "a", "b", "c"),
((2,2,2,5,5),<a b c>),
'snip with a type object';


# vim: expandtab shiftwidth=4