File: 01basic.t

package info (click to toggle)
libsub-recursive-perl 0.05-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 120 kB
  • sloc: perl: 60; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 384 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use Test::More tests => 1 + 4;
BEGIN { require_ok('Sub::Recursive') };

#########################

use strict;

BEGIN { use_ok('Sub::Recursive') };

my $fac = recursive { $_[0] ? $_[0] * $REC->($_[0]-1) : 1 };

is($fac->(5), 120, 'main, $fac->(5)');

is(recursive { $_[0] ? $_[0] * $REC->($_[0]-1) : 1 }->(5), 120, 'inline fac');

package Foo;
::is($fac->(5), 120, 'Foo, $fac->(5)');