File: Case-Scoping.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 (34 lines) | stat: -rw-r--r-- 656 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl
package CaseScoping;
use strict;
use warnings;

use Fennec;

my $var;
my $before_var;
my $before_all;

case alpha => sub { $var = 'a' };
case bravo => sub { $var = 'b' };

before_all clear_the_room => sub {
    # If scoping works properly, this should have no case applied
    $before_all = $var;
};

before_each set_the_before => sub {
    # If scoping works properly, we should hit this twice, once
    # for alpha and once for bravo, with $var set appropriately.
    $before_var = $var;
};

tests check_before_each => sub {
    is( $before_var, $var );
};

tests check_before_all => sub {
    is( $before_all, undef );
};

done_testing;