Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created December 24, 2017 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/3017d65e87088d3c5fe18791a1f6340c to your computer and use it in GitHub Desktop.
Save zoffixznet/3017d65e87088d3c5fe18791a1f6340c to your computer and use it in GitHub Desktop.
use v6;
use Test;
# L<S32::Containers/"Array"/"=item splice">
=begin description
This test tests the C<splice> builtin
=end description
sub splice-ok(\ret, \ret_exp, \rem, \rem_exp, Str $comment) {
subtest {
plan 4;
is ret.WHAT, ret_exp.WHAT, 'return types match';
is ret, ret_exp, 'return results match';
is rem.WHAT, rem_exp.WHAT, 'remainder types match';
is rem, rem_exp, 'remainder results match';
}, $comment;
}
my int64 @int64;
my @testing = $@int64, array[int64];
plan (@testing/2 * 54) + 15;
for @testing -> @a, $T {
my $toNum = @a.of ~~ Num;
sub submeth-ok(\values,\params,\return,\remain,$comment){
splice(@a,|params);
dd [@a, params];
@a = values;
@a.splice(|params);
dd [@a, params];
@a = values;
@a.splice(|params);
dd [@a, params];
}
#---------------------+--------+---------+----------+---------------------------
# init | params | return | remain | comment
#---------------------+--------+---------+----------+---------------------------
submeth-ok (1..10), (), (1..10), (), 'whole';
submeth-ok (1..12), (0,1), (1,), (2..12), 'simple 1 elem';
submeth-ok (^10), (10,0,10,11), (), (^12), 'push two';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment