Apache-ASP
view release on metacpan or search on metacpan
my $self = shift;
$self->{t}++;
$self->{buffer} .= "ok $self->{t} # skip\n";
}
sub ok {
$_[0]->{t}++;
$_[0]->{buffer} .= "ok\n";
}
*not = *not_ok;
sub not_ok {
my($self, $warn) = @_;
if($warn) {
warn "[failure] $warn";
}
$self->{t}++;
$self->{buffer} .= "not ok\n";
}
sub test {
my($self) = @_;
my($k, $v);
while(($k, $v) = each %{$self->{data}}) {
$test = "$k=$v";
if($self->{input} =~ /\[\[$test\]\]/) {
$self->ok();
} else {
$self->not_ok();
print "$test data not found\n";
}
}
}
sub done {
my $self = shift;
return if $self->{done}++;
print "1..$self->{t}\n";
print $self->{buffer};
t/general.t view on Meta::CPAN
use Apache::ASP::CGI;
&Apache::ASP::CGI::do_self();
__END__
<%@ LANGUAGE="PerlScript" %>
<%
for(@Apache::ASP::Objects) {
if(${$_}) {
$t->ok;
} else {
$t->not_ok("object $_ not defined in ASP namespace");
}
}
%>
t/global.asa view on Meta::CPAN
sub my::deeptag {
$t->ok;
$Deep++;
}
sub my::tag_check_value {
my $args = shift;
if($args->{value}) {
$t->ok;
} else {
$t->not_ok;
}
}
sub my::tag_check_value_ref {
my($args) = shift;
if(ref $args->{value}) {
$t->ok;
} else {
$t->not_ok;
}
}
sub my::tag_check_value_not_ref {
my($args) = shift;
if(ref $args->{value}) {
$t->not_ok;
} else {
$t->ok;
}
}
sub my::returnok {
$t->eok($_[1] eq 'ok', 'String return');
}
sub my::args {
t/global_event_end.t view on Meta::CPAN
#!/usr/bin/perl
use Apache::ASP::CGI;
&Apache::ASP::CGI::do_self(Global => 'global_event_end', NoState => 1);
__END__
<% $t->not_ok; %>
t/global_event_end/global.asa view on Meta::CPAN
use vars qw($t);
use lib qw(.);
use T;
sub Script_OnStart {
$t = T->new;
$t->ok;
$Response->End;
$t->not_ok;
}
sub Script_OnEnd {
$t->done;
}
t/include.t view on Meta::CPAN
__END__
<% use lib '.'; use T; $t =T->new(); %>
<!--#include file="include_asp.inc"-->
<% $Response->Include("include_asp.inc"); %>
<%
# normal shape of include command
if('<!--#include file="include.inc"-->' =~ /^1/) {
$t->ok();
} else {
$t->not_ok;
}
#$Response->Debug($Server->{asp});
# should parse both in at once
if('<!--#include file="include.inc"-->' =~ /^1/) {
$t->ok();
} else {
$t->not_ok;
}
# test again for multiple includes to mess
# up the line numbering
%><!--#include file="include_asp.inc"--><%
#abnormal possible use of include command
if(
'<!--#include
file = "include.inc"
-->' =~ /^1/) {
$t->ok();
} else {
$t->not_ok;
}
my $trapped = $Response->TrapInclude('include.inc');
$t->eok($$trapped eq '1', '$Response->TrapInclude()');
$Response->Include('include.inc');
my $ref = $Response->{BinaryRef};
$t->eok($$ref =~ /1/, '$Response->Include()');
$$ref =~ s/1//isg;
$main::TestLoad = 0;
Apache::ASP->Loader('load.inc', undef, Debug => 1, Execute => 1);
$t->eok($main::TestLoad, "failed to execute load.inc while loading");
my $error_mark;
{
# Apache::ASP->Loader() uses warn() aliased to Apache::ASP::Warn() to put out error messages
$^W = 0;
local *Apache::ASP::Warn = sub {
my $log_output = join("", @_);
if($log_output =~ /not_scoped_variable/is) {
$error_mark = $log_output;
} else {
warn(@_);
}
};
$^W = 1;
Apache::ASP->Loader('load_error.inc', undef, Debug => 1, UseStrict => 1);
}
$t->eok($error_mark, "failed to catch compile error of load_error.inc while loading");
t/load_error.inc view on Meta::CPAN
<%
$not_scoped_variable = 1;
# $Response->AppendToLog("loader logging ok %!");
# $Response->Debug("loader debugging ok %!");
%>
<% use lib '.'; use T; $t =T->new(); %>
<%
my $count = 0;
for(1..3) {
$count++;
}
if($count == 3) {
$t->ok;
} else {
$t->not_ok("for loop didn't work");
}
$count = 0;
while(1) {
last if (++$count > 2);
}
if($count == 3) {
$t->ok;
} else {
$t->not_ok("while loop didn't work");
}
$t->done;
%>
t/request.t view on Meta::CPAN
&Apache::ASP::CGI::do_self( NoState => 1 );
__END__
<% use lib '.'; use T; $t =T->new(); %>
<%
if(%{$Request->ServerVariables()}) {
$t->ok();
} else {
$t->not_ok('could not get the environment / server variables');
}
# $Request->{Method}, defaults to GET
$t->eok($Request->{Method} eq 'GET', "\$Request->{Method} eq 'GET'");
%>
<% $t->done; %>
t/response_end.t view on Meta::CPAN
use Apache::ASP::CGI;
&Apache::ASP::CGI::do_self(NoState => 1);
__END__
<%
$t->ok;
$Response->End;
$t->not_ok;
%>
__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',
t/session_query_parse.t view on Meta::CPAN
'<a href="/somelink.asp?test1=value1&test2=value2&session-id=',
"<frame src='somelink.asp?test3=value3&test4=value4&session-id=",
"<form action=/somelink.asp?test5=value5&test6=value6&session-id="
);
for my $test ( @tests ) {
$test =~ s/(\W)/\\$1/isg;
if($body =~ /$test/s) {
$t->ok;
} else {
$t->not_ok;
}
}
$t->done;
__END__
<a href="/somelink.asp?test1=value1&test2=value2">Some Link</a>
<frame src='<%= $Server->URL("somelink.asp?test3=value3", { test4 => "value4" }) %>'>
t/xmlsubs_aspargs.t view on Meta::CPAN
/>
<my:args ok="<%= $ref->{ok} %>" />
<my:args ok="1<%= $ref->{ok} %>"></my:args>
<my:tag_check_value value="<%= $ref %>" />
<my:tag_check_value value="<%= '' %><%= 1 %>" />
<my:tag_check_value value="<%= '' %><%= 1 %><%= '' %>" />
<my:tag_check_value_ref value="<%= $ref %>" />
<my:tag_check_value_ref value='<%= $ref->{ref} %>' />
<my:tag_check_value_not_ref value='<%= $ref->{ref} %> ' />
<my:tag_check_value_not_ref value='<%= $ref->{ref} %><%= $ref %>' />
<my:tag-check-value value="1" />
<my:deeptag />
<% $t->eok($Deep == 3, "Deep tag to call twice"); %>
<my:args
error="Multiline Arguments"
ok="1"
></my:args>
( run in 0.677 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )