File: attributes.t

package info (click to toggle)
libfunction-parameters-perl 2.002005-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 624 kB
  • sloc: perl: 3,945; makefile: 3
file content (55 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!perl

use Test::More tests => 10;

use warnings FATAL => 'all';
use strict;

use Function::Parameters {
    fun => 'function',
    method => 'method',
    elrond => {
        attributes => ':lvalue',
    },
};

is eval('use Function::Parameters { fun => { attributes => "nope" } }; 1'), undef;
like $@, qr/nope.*attributes/;

is eval('use Function::Parameters { fun => { attributes => ": in valid {" } }; 1'), undef;
like $@, qr/in valid.*attributes/;

elrond hobbard($ref) { $$ref }
{
    my $x = 1;
    hobbard(\$x) = 'bling';
    is $x, 'bling';

}
$_ = 'fool';
chop hobbard \$_;
is $_, 'foo';

{
    package BatCountry;

    fun join($group, $peer) {
        return "* $peer has joined $group";
    }

    ::is eval('join("left", "right")'), undef;
    ::like $@, qr/Ambiguous.*CORE::/;
}

{
    package CatCountry;

    method join($peer) {
        return "* $peer has joined $self->{name}";
    }

    ::is join('!', 'left', 'right'), 'left!right';

    my $obj = bless {name => 'kittens'};
    ::is $obj->join("twig"), "* twig has joined kittens";
}