File: collection.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 (39 lines) | stat: -rw-r--r-- 1,326 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
use Apache::ASP::CGI;
&Apache::ASP::CGI::do_self(NoState => 0);

__END__

<% 
for('Form', 'QueryString') {
    %{$Request->{$_}} = ();

    # basic assignment & lookup
    my $self = $t->eok($Request->$_(), "no collection for $_ found");
    $Request->$_('test', 'value');
    $t->eok($self->{'test'} eq 'value', "count not set value");
    $t->eok($Request->$_('test') eq 'value', "could not fetch value");
    
    # array assignment & lookup
    $self->{'array'} = [1,0,2];
    my @values = $Request->$_('array');
    $t->eok(@values == 3, 'array block lookup test failed');
    my $value = $Request->$_('array');
    $t->eok($value == 1, 'array single lookup test failed');

    # Count() & Key() tests
    $t->eok($Request->$_()->Count == 2, 'collection count failed');
    my $key = $Request->$_()->Key(1);
    $t->eok($key eq 'array', "key lookup failed for 1st item, got $key of keys ".
	    join(',', sort keys %{$Request->{$_}}));
    
    # Item syntax
    $t->eok($Request->$_()->Item('test') eq 'value', '$Collection->Item(key) lookup syntax');
    $Request->$_()->Item('test', 'value2');
    $t->eok($self->{'test'} eq 'value2', '$Collection->Item(key, value) assignment syntax');
    
}

$Application->{contents} = 1;
$t->eok($Application->Contents('contents'), '$Collection->Contents(key) lookup syntax');
%>