File: nested.t

package info (click to toggle)
libfile-chdir-perl 0.1008-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 482; makefile: 52
file content (39 lines) | stat: -rw-r--r-- 532 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
#!/usr/bin/env perl -w

# Test that File::chdir works when multiple packages have nested, localized $CWD.

use strict;
use warnings;

use Test::More;

use File::chdir;

my $original_cwd = $CWD.'';

{
    package Inner;
    use File::chdir;

    sub foo {
        local $CWD = File::Spec->catdir($original_cwd, "lib");
    }
}


{
    package Outer;
    use File::chdir;

    sub bar {
        local $CWD = File::Spec->catdir($original_cwd, "t");
        Inner::foo();
    }
}


Outer::bar();
is $CWD, $original_cwd;


done_testing;