summaryrefslogtreecommitdiffstats
path: root/t/recursion.t
blob: 0b13da9170cd29bbbb8ae51c18906bc40c32afe0 (plain) (blame)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

BEGIN {
    if (!eval { require 5.016; 1 }) {
        plan skip_all => "This test requires 5.16";
    }
}

use 5.016;

use Fun;

fun fact ($n) {
    if ($n < 2) {
        return 1;
    }
    return $n * __SUB__->($n - 1);
}

is(fact(5), 120);

done_testing;