File: perlrun_extload.pl

package info (click to toggle)
libapache2-mod-perl2 2.0.13-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 12,016 kB
  • sloc: perl: 97,771; ansic: 14,493; makefile: 51; sh: 18
file content (62 lines) | stat: -rw-r--r-- 2,202 bytes parent folder | download | duplicates (7)
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
61
62
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
use warnings;
use strict;

use Apache::Test ();
use Apache::TestUtil;
use File::Spec::Functions qw(catfile catdir);

use lib catdir Apache::Test::vars('serverroot'), 'cgi-bin';
my $require = catfile Apache::Test::vars('serverroot'),
    qw(cgi-bin perlrun_nondecl.pl);

print "Content-type: text/plain\n\n";

### declared package module ###
{
    # require a module w/ package declaration (it doesn't get reloaded
    # because it declares the package). But we still have a problem with
    # subs declaring prototypes. When perlrun_decl->import is called, the
    # original function's prototype doesn't match the aliases prototype.
    # see decl_proto()
    BEGIN { t_server_log_warn_is_expected()
                if perlrun_decl->can("decl_proto");
    }
    use perlrun_decl;

    die "perlrun_decl BEGIN block was run more than once"
        if $MyData::blocks{perlrun_decl} > 1;

    print "d";
    print decl_proto(1);
}

### non-declared package module ###
{
    # how many times were were called from the same interpreter
    $MyData::blocks{cycle}{perlrun_nondecl}++;
    $MyData::blocks{BEGIN}{perlrun_nondecl} ||= 0;
    $MyData::blocks{END}  {perlrun_nondecl} ||= 0;

    # require a lib w/o package declaration. Functions in that lib get
    # automatically aliased to the functions in the current package.
    require "$require";

    die "perlrun_nondecl's BEGIN block wasn't run"
        if $MyData::blocks{BEGIN}{perlrun_nondecl} !=
           $MyData::blocks{cycle}{perlrun_nondecl};

    # the END block for this cycle didn't run yet, but we can test the
    # previous cycle's one
    die "perlrun_nondecl's END block wasn't run"
        if $MyData::blocks{END}{perlrun_nondecl} + 1 !=
           $MyData::blocks{cycle}{perlrun_nondecl};

    # they all get redefined warning inside perlrun_nondecl.pl, since that
    # lib loads it into main::, vs. PerlRun undefs the current __PACKAGE__
    print "nd";
    print nondecl_no_proto();
    print nondecl_proto(2);
    print nondecl_proto_empty("whatever");
    print nondecl_const();
}