File: data_end.t

package info (click to toggle)
libcgi-compile-perl 0.27-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 248 kB
  • sloc: perl: 372; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 986 bytes parent folder | download | duplicates (2)
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
use Test::More;
use CGI::Compile;
use Capture::Tiny 'capture_stdout';

{
    my $sub = CGI::Compile->compile("t/data.cgi");
    my $out = capture_stdout { $sub->() };
    like $out, qr/Hello\nWorld/;
}

{
    my $sub = CGI::Compile->compile("t/data_crlf.cgi");
    my $out = capture_stdout { $sub->() };
    like $out, qr/Hello\r?\nWorld/;
}

eval {
    my $sub = CGI::Compile->compile("t/end.cgi");
};

is $@, '';

eval {
    my $sub = CGI::Compile->compile("t/end_crlf.cgi");
};

is $@, '';

{
    local $main::FLNO;
    my $sub = CGI::Compile->compile(\<<'EOF');
$main::FLNO = fileno DATA;
print +(<DATA>)[0,3];
__DATA__
line 1
line 2
line 3
line 4
EOF

    my $out = capture_stdout { $sub->() };
    like $out, qr/line 1\r?\nline 4/;

    $out = capture_stdout { $sub->() };
    like $out, qr/line 1\r?\nline 4/;

    is $main::FLNO, -1;
}

{
    local $main::S;
    my $sub = CGI::Compile->compile(\<<'EOF');
$main::S = $^S;
EOF

    $sub->();
    is $main::S, 1;
}

done_testing;