File: around_all.t

package info (click to toggle)
libfennec-perl 2.018-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 384 kB
  • sloc: perl: 2,083; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 754 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl
use strict;
use warnings;

use Fennec;

my $parent_pid = $$;

describe set => sub {
    my $pid;
    my $count = 0;
    my $count2 = 0;
    my $count3 = 0;

    before_all blah => sub {
        $count2++;
    };

    around_each bar => sub {
        is( $count3, 1, "already 1" );
        $count3++;
    };

    around_all foo => sub {
        my $self = shift;
        my ($run) = @_;
        $count++;
        $pid = $$;

        $count3++;

        $run->();
    };

    for my $i ( 1 .. 10 ) {
        tests $i => sub {
            is( $count, 1, "ran once" );
            is( $count2, 1, "ran once" );
            is( $count3, 2, "both ran" );
            is( $pid, $parent_pid, "ran in parent" );
        };
    }
};

done_testing;