Commit | Line | Data |
231ddb47 |
1 | #!perl |
2 | |
3 | use Test::More tests => 10; |
4 | |
5 | use warnings FATAL => 'all'; |
6 | use strict; |
7 | |
8 | use Function::Parameters { |
9 | fun => 'function', |
10 | method => 'method', |
11 | elrond => { |
12 | attrs => ':lvalue', |
13 | }, |
14 | }; |
15 | |
16 | is eval('use Function::Parameters { fun => { attrs => "nope" } }; 1'), undef; |
17 | like $@, qr/nope.*attributes/; |
18 | |
19 | is eval('use Function::Parameters { fun => { attrs => ": in valid {" } }; 1'), undef; |
20 | like $@, qr/in valid.*attributes/; |
21 | |
22 | elrond hobbard($ref) { $$ref } |
23 | { |
24 | my $x = 1; |
25 | hobbard(\$x) = 'bling'; |
26 | is $x, 'bling'; |
27 | |
28 | } |
29 | $_ = 'fool'; |
30 | chop hobbard \$_; |
31 | is $_, 'foo'; |
32 | |
33 | { |
34 | package BatCountry; |
35 | |
36 | fun join($group, $peer) { |
37 | return "* $peer has joined $group"; |
38 | } |
39 | |
40 | ::is eval('join("left", "right")'), undef; |
41 | ::like $@, qr/Ambiguous.*CORE::/; |
42 | } |
43 | |
44 | { |
45 | package CatCountry; |
46 | |
47 | method join($peer) { |
48 | return "* $peer has joined $self->{name}"; |
49 | } |
50 | |
51 | ::is join('!', 'left', 'right'), 'left!right'; |
52 | |
53 | my $obj = bless {name => 'kittens'}; |
54 | ::is $obj->join("twig"), "* twig has joined kittens"; |
55 | } |