Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 38 lines (27 sloc) 1.341 kb
dc30b33 [t/spec] add basic tests for slurpy parameters
moritz authored
1 use v6;
2 use Test;
3
297e783 [t] and [t/spec]
moritz authored
4 plan 13;
dc30b33 [t/spec] add basic tests for slurpy parameters
moritz authored
5
6 sub xelems(*@args) { @args.elems }
7 sub xjoin(*@args) { @args.join('|') }
8
9 is xelems(1), 1, 'Basic slurpy params 1';
10 is xelems(1, 2, 5), 3, 'Basic slurpy params 2';
11
12 is xjoin(1), '1', 'Basic slurpy params 3';
13 is xjoin(1, 2, 5), '1|2|5', 'Basic slurpy params 4';
14
15 sub mixed($pos1, *@slurp) { "|$pos1|" ~ @slurp.join('!') }
16
17 is mixed(1), '|1|', 'Positional and slurp params';
18 is mixed(1, 2, 3), '|1|2!3', 'Positional and slurp params';
297e783 [t] and [t/spec]
moritz authored
19 dies_ok { mixed()}, 'at least one arg required';
dc30b33 [t/spec] add basic tests for slurpy parameters
moritz authored
20
7acf702 [t/spec] fudge slurpy-params.t for rakudo
moritz authored
21 #?rakudo skip 'types on slurpy params'
098b49a [t] merged blocks/splatty_with_type.t into spec/
moritz authored
22 {
23 sub x_typed_join(Int *@args){ @args.join('|') }
24 is x_typed_join(1), '1', 'Basic slurpy params with types 1';
25 is x_typed_join(1, 2, 5), '1|2|5', 'Basic slurpy params with types 2';
c2f8fec [t] and [t/spec] (two train travels worth of changes):
moritz authored
26 dies_ok { x_typed_join(3, 'x') }, 'Types on slurpy params are checked';
098b49a [t] merged blocks/splatty_with_type.t into spec/
moritz authored
27 }
28
297e783 [t] and [t/spec]
moritz authored
29 sub first_arg ( *@args ) { ~@args[0]; }
30 sub first_arg_rw ( *@args is rw ) { ~@args[0]; }
31 sub first_arg_copy ( *@args is copy ) { ~@args[0]; }
32
33 is first_arg(1, 2, 3), '1', 'can grab first item of a slurpy array';
34 is first_arg_rw(1, 2, 3), '1', 'can grab first item of a slurpy array (is rw)';
35 is first_arg_copy(1, 2, 3), '1', 'can grab first item of a slurpy array (is copy)';
36
dc30b33 [t/spec] add basic tests for slurpy parameters
moritz authored
37 # vim: ft=perl6
Something went wrong with that request. Please try again.