File: eval.t

package info (click to toggle)
libfunction-parameters-perl 2.001003-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 948 kB
  • sloc: perl: 6,478; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (2)
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
#!perl
use strict;
use warnings FATAL => 'all';
use Test::More tests => 8;

use Function::Parameters;

eval 'fun foo ($bar) { $bar }';
ok(!$@, 'signatures parse in eval');
diag $@ if $@;
ok(\&foo, 'fun declared in eval');
is(foo(42), 42, 'eval signature works');

no Function::Parameters;

$SIG{__WARN__} = sub {};
eval 'fun bar ($baz) { $baz }';
like($@, qr/requires explicit package name/, 'string eval disabled');

{
    use Function::Parameters;

    eval 'fun bar ($baz) { $baz }';
    ok(!$@, 'signatures parse in eval');
    diag $@ if $@;
    ok(\&bar, 'fun declared in eval');
    is(bar(42), 42, 'eval signature works');
}

$SIG{__WARN__} = sub {};
eval 'fun moo ($kooh) { $kooh }';
like($@, qr/requires explicit package name/, 'string eval disabled');