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 (38 lines) | stat: -rw-r--r-- 682 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
33
34
35
36
37
38
#!perl
use strict;
use warnings FATAL => 'all';

use Test::More tests => 3;    # last test to print
use Function::Parameters qw(:strict);


my $evalcode = do {
    local $/ = undef;
    <DATA>;
};

ok(
    do {
        my $r = eval $evalcode;
        die $@ if not $r;
        1;
    },
    'Basic Eval Moose'
);

my $foo = foo->new({});
is ($foo->example (), 1, 'First method declared');
is ($foo->example2(), 2, 'Second method declared (after injected semicolon)');

__DATA__
{
    package foo;

    use Function::Parameters qw(:strict);
    method new($class: $init) { bless $init, $class }
    method example()  { 1 } # look Ma, no semicolon!
    method example2() { 2 }
}
1;