File: code.t

package info (click to toggle)
libdata-perl-perl 0.002011-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 252 kB
  • sloc: perl: 364; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use Test::More;
use Data::Perl;
use strict;
use Scalar::Util qw/reftype/;
use Test::Fatal qw/dies_ok/;

# constructor
is ref(code(sub{})), 'Data::Perl::Code', 'constructor shortcut works';
is code->execute, undef, 'execute on blank sub returns correct undef';

my $b = code(sub { 2 });
is reftype($b), 'CODE', 'inner struct is coderef of ctr';

is $b->(), 2, 'coderef returns correct value';

is $b->execute, 2, 'execute returns correct value';

# tbd: execute_method

dies_ok {
  $b->execute_method;
} 'execute_method fails for now.';

done_testing();