File: Table.t

package info (click to toggle)
libapreq2-perl 2.04-dev-1sarge2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,700 kB
  • ctags: 1,508
  • sloc: sh: 8,103; ansic: 5,557; perl: 2,842; cpp: 1,052; makefile: 234
file content (216 lines) | stat: -rw-r--r-- 3,746 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/perl -w

use Test::More 'no_plan';

package Catch;

sub TIEHANDLE {
    my($class, $var) = @_;
    return bless { var => $var }, $class;
}

sub PRINT  {
    my($self) = shift;
    ${'main::'.$self->{var}} .= join '', @_;
}

sub OPEN  {}    # XXX Hackery in case the user redirects
sub CLOSE {}    # XXX STDERR/STDOUT.  This is not the behavior we want.

sub READ {}
sub READLINE {}
sub GETC {}
sub BINMODE {}

my $Original_File = 'docs/Table.pod';

package main;

# pre-5.8.0's warns aren't caught by a tied STDERR.
$SIG{__WARN__} = sub { $main::_STDERR_ .= join '', @_; };
tie *STDOUT, 'Catch', '_STDOUT_' or die $!;
tie *STDERR, 'Catch', '_STDERR_' or die $!;

{
    undef $main::_STDOUT_;
    undef $main::_STDERR_;
#line 6 docs/Table.pod
    use Apache2;
    use Apache::Upload;
    use Apache::Cookie;
    use APR::Pool;
    use APR::Table;
    $r = APR::Pool->new; # environment object

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
}

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
eval q{
  my $example = sub {
    local $^W = 0;

#line 18 docs/Table.pod

    my $table = Apache::Request::Table->new($r);
    $table->{test} = 1;
    $table->{foo} = "bar1";
    $table->add(foo => "bar2");

    {
        my $do_data = "";
        $table->do( sub { $do_data .= "@_,"; 1 } );
        ok $do_data eq "test 1,foo bar1,foo bar2,";
    }




;

  }
};
is($@, '', "example from line 18");

{
    undef $main::_STDOUT_;
    undef $main::_STDERR_;
#line 18 docs/Table.pod

    my $table = Apache::Request::Table->new($r);
    $table->{test} = 1;
    $table->{foo} = "bar1";
    $table->add(foo => "bar2");

    {
        my $do_data = "";
        $table->do( sub { $do_data .= "@_,"; 1 } );
        ok $do_data eq "test 1,foo bar1,foo bar2,";
    }




  #run the above tests, don't just compile them

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
}

    undef $main::_STDOUT_;
    undef $main::_STDERR_;

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
eval q{
  my $example = sub {
    local $^W = 0;

#line 58 docs/Table.pod

    my $table = Apache::Request::Table->new($r);
    my $value = "bar\0quux";
    $table->{foo} = $value;




;

  }
};
is($@, '', "example from line 58");

{
    undef $main::_STDOUT_;
    undef $main::_STDERR_;
#line 58 docs/Table.pod

    my $table = Apache::Request::Table->new($r);
    my $value = "bar\0quux";
    $table->{foo} = $value;




    is $table->{foo}, $value;

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
}

    undef $main::_STDOUT_;
    undef $main::_STDERR_;

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
eval q{
  my $example = sub {
    local $^W = 0;

#line 78 docs/Table.pod

    my $upload = Apache::Upload->new($r, name => "foo", file => __FILE__);
    my $table = Apache::Upload::Table->new($r);
    $table->add($upload);
    $upload = $table->{foo};




;

  }
};
is($@, '', "example from line 78");

{
    undef $main::_STDOUT_;
    undef $main::_STDERR_;
#line 78 docs/Table.pod

    my $upload = Apache::Upload->new($r, name => "foo", file => __FILE__);
    my $table = Apache::Upload::Table->new($r);
    $table->add($upload);
    $upload = $table->{foo};




    ok $upload->isa("Apache::Upload");

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
}

    undef $main::_STDOUT_;
    undef $main::_STDERR_;

    undef $main::_STDOUT_;
    undef $main::_STDERR_;
eval q{
  my $example = sub {
    local $^W = 0;

#line 99 docs/Table.pod

    my $cookie = Apache::Cookie->new($r, name =>"foo", value => "bar");
    my $table = Apache::Cookie::Table->new($r);
    $table->{foo} = $cookie;
    $cookie = $table->{foo};





;

  }
};
is($@, '', "example from line 99");

    undef $main::_STDOUT_;
    undef $main::_STDERR_;