File: server.t

package info (click to toggle)
libapache-asp-perl 2.62-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 4,108 kB
  • ctags: 830
  • sloc: perl: 6,033; php: 417; sh: 65; lisp: 22; makefile: 10
file content (52 lines) | stat: -rw-r--r-- 1,714 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
use Apache::ASP::CGI;
&Apache::ASP::CGI::do_self(NoState => 1, Debug => 0);
$SIG{__DIE__} = \&Carp::confess;

__END__

<% use lib '.';	use T;	$t =T->new(); %>

<% 
my $encode = $Server->URLEncode("test data");
if($encode eq 'test%20data') {
	$t->ok();
} else {
	$t->not_ok('URLEncode not working');
}

$Server->Config('Global', '.');
$t->eok(sub { $Server->Config('Global') eq '.' }, 
	'Global must be defined as . for test'
	);
my $config = $Server->Config;
$t->eok($config->{Global} eq '.', 'Full config as hash');
$t->eok($Server->URL('test.asp', { 'test ' => ' value ' } )
	eq 'test.asp?test%20=%20value%20',
	'basic $Server->URL() encoding did not work'
	);
$t->eok($Server->URL('test.asp', { 'test' => ['value', 'value2'] })
	eq 'test.asp?test=value&test=value2',
	'multi params $Server->URL() encoding did not work'
	);
$t->eok($Server->URL('test.asp')
	eq 'test.asp',
	'no args $Server->URL() encoding did not work'
	);

my $html = q(&"<>'abc);
my $final = '&amp;&quot;&lt;&gt;&#39;abc';
my $result = $Server->HTMLEncode($html);
$t->eok($result eq $final, "\$Server->HTMLEncode('$html')");
my $ref_result = $Server->HTMLEncode(\$html);
$t->eok(\$html eq $ref_result, "\$Server->HTMLEncode(\\\$html) should output same ref as going in");
$t->eok($html eq $final, "$html does not equal $final");
$t->eok($Server->MapInclude('server.t') eq './server.t', "Find executing script in Includes path");
$t->eok($Server->File =~ /server.t$/, "\$Server->File does not match");

#use Benchmark;
#my $htmlbig = '&"<>' x 25000;
#timethis(10, sub { my $copy = $htmlbig; $copy = $Server->HTMLEncode($copy) });
#timethis(10, sub { my $copy = $htmlbig; $Server->HTMLEncode(\$copy) });

$Server->Transfer('transfer.inc');
%>