diff --git a/S17-supply/snip.t b/S17-supply/snip.t new file mode 100644 index 0000000000..cd037c8477 --- /dev/null +++ b/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 diff --git a/S32-list/snip.t b/S32-list/snip.t new file mode 100644 index 0000000000..f8e5d5c6a5 --- /dev/null +++ b/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),), + 'snip with a type object'; + + +# vim: expandtab shiftwidth=4