File: symbols.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 (43 lines) | stat: -rw-r--r-- 768 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
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use CGI::Compile;
use Capture::Tiny 'capture_stdout';
use Test::Requires 'Sub::Identify';

use Sub::Identify qw/sub_name stash_name/;

my $cgi =<<'EOL';
#!/usr/bin/perl

print "Content-Type: text/plain\015\012\015\012", <DATA>;

__DATA__
Hello
World
EOL

my $sub = CGI::Compile->compile(\$cgi);

is sub_name($sub),   '__CGI0__';
is stash_name($sub), 'main';

$sub = CGI::Compile->compile('t/hello.cgi');

is sub_name($sub), 'hello_2ecgi';

like stash_name($sub), qr/^CGI::Compile::ROOT::[A-Za-z0-9_]*t_hello_2ecgi\z/;

$sub = CGI::Compile->compile(\$cgi);

is sub_name($sub),   '__CGI1__';
is stash_name($sub), 'main';

my $out = capture_stdout { $sub->() };

like $out, qr/Hello\nWorld/;

done_testing;