File: goto_file.t

package info (click to toggle)
libgoto-file-perl 0.005-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 152 kB
  • sloc: perl: 72; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package A::Test::Package;
use Test2::V0 -target => 'goto::file';
use Test2::IPC;
use Test2::Require::RealFork;

use File::Temp qw/tempfile/;

use ok $CLASS;

BEGIN {

    # This filter is designed to work along with forking, so we test it with
    # forking.
    my $pid = fork();
    die "Could not fork" unless defined $pid;

    if ($pid) {
        # Let the child finish first.
        my $check = waitpid($pid, 0);
        my $exit = $?;

        is($check, $pid, "was able to wait on other process");
        ok(!$exit, "Other process exited fine");

        plan 8;
        exit 0;
    }
    else {
        my ($fh, $filename) = tempfile(CLEANUP => 1);
        print $fh <<"        EOT";
use Test2::V0;

is(__LINE__, 3, "line numbers are correct");
is(__FILE__, "$filename", "Got filename");
is(__PACKAGE__, "main", "in main package");

is([caller(0)], [], "no caller");

is(
    [<DATA>],
    ["foo\\n", "bar\\n", "baz\\n"],
    "Got data section"
);

# Edge cases suck :-(
__DATA__
foo
bar
baz
        EOT
        close($fh);
        goto::file->import($filename);
    }
}

die "Should not get here!\n";

__DATA__

Should not see this data!