steal more tests from other modules
[p5sagit/Function-Parameters.git] / t / foreign / Method-Signatures / slurpy.t
CommitLineData
633048d5 1#!perl
2
3# Test slurpy parameters
4
5use strict;
6use warnings FATAL => 'all';
7
8use Test::More;
9
10{
11 package Stuff;
12 use Function::Parameters qw(:strict);
13 use Test::More;
14
15 method slurpy(@that) { return \@that }
16 method slurpy_required(@that) { return \@that }
17 method slurpy_last($this, @that) { return $this, \@that; }
18
19 ok !eval q[fun slurpy_first(@that, $this) { return $this, \@that; }];
20 like $@, qr{\@that\b.+\$this\b};
21 TODO: {
22 #local $TODO = "error message incorrect inside an eval";
23
24 like $@, qr{\bslurpy_first\b};
25 }
26
27 ok !eval q[fun slurpy_middle($this, @that, $other) { return $this, \@that, $other }];
28 like $@, qr{\@that\b.+\$other\b};
29 TODO: {
30 #local $TODO = "error message incorrect inside an eval";
31
32 like $@, qr{\bslurpy_middle\b};
33 }
34
98e6239b 35 ok !eval q[fun slurpy_positional(:@that) { return \@that; }];
36 like $@, qr{\bnamed\b.+\@that\b.+\barray\b};
633048d5 37
38 ok !eval q[fun slurpy_two($this, @that, @other) { return $this, \@that, \@other }];
39 like $@, qr{\@that\b.+\@other\b};
40}
41
42
43note "Optional slurpy params accept 0 length list"; {
44 is_deeply [Stuff->slurpy()], [[]];
45 is_deeply [Stuff->slurpy_last(23)], [23, []];
46}
47
48#note "Required slurpy params require an argument"; {
49# throws_ok { Stuff->slurpy_required() }
50# qr{slurpy_required\Q()\E, missing required argument \@that at \Q$0\E line @{[__LINE__ - 1]}};
51#}
52
53
54done_testing;