File: lexical.t

package info (click to toggle)
libfunction-parameters-perl 2.002005-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 624 kB
  • sloc: perl: 3,945; makefile: 3
file content (62 lines) | stat: -rw-r--r-- 1,124 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
56
57
58
59
60
61
62
#!perl

use Test::More tests => 16;

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

sub Burlap::fun (&) { $_[0]->() }

{
    use Function::Parameters;

    is fun () { 2 + 2 }->(), 4;

    package Burlap;

    ::ok fun () { 0 };
}

{
    package Burlap;

    ::is fun { 'singing' }, 'singing';
}

{
    sub proc (&) { &Burlap::fun }

    use Function::Parameters { proc => 'function' };

    proc add($x, $y) {
        return $x + $y;
    }

    is add(@{[2, 3]}), 5;

    {
        use Function::Parameters;

        is proc () { 'bla' }->(), 'bla';
        is method () { $self }->('der'), 'der';

        {
            no Function::Parameters;

            is proc { 'unk' }, 'unk';

            is eval('fun foo($x) { $x; } 1'), undef;
            like $@, qr/syntax error/;
        }

        is proc () { 'bla' }->(), 'bla';
        is method () { $self }->('der'), 'der';

        no Function::Parameters 'proc';
        is proc { 'unk2' }, 'unk2';
        is method () { $self }->('der2'), 'der2';
    }
    is proc () { 'bla3' }->(), 'bla3';
    is eval('fun foo($x) { $x; } 1'), undef;
    like $@, qr/syntax error/;
}