/
cgi_query_hash.t
72 lines (51 loc) · 1.53 KB
/
cgi_query_hash.t
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
#!./parrot
# Copyright (C) 2006-2010, Parrot Foundation.
=head1 NAME
t/library/cgi_query_hash.t - test [ 'CGI'; 'QueryHash' ]
=head1 SYNOPSIS
% prove t/library/cgi_query_hash.t
=head1 DESCRIPTION
Test [ 'CGI'; 'QueryHash' ]
=cut
.sub test :main
load_bytecode "dumper.pbc"
.include 'test_more.pir'
load_bytecode 'CGI/QueryHash.pbc'
plan(7)
.local int is_defined
.local pmc query_hash
.local string val
.local pmc parse_get_sub
parse_get_sub = get_global [ 'CGI'; 'QueryHash' ], 'parse_get'
is_defined = defined parse_get_sub
ok( is_defined, 'got the sub "parse_get"' )
# set up environment
.local pmc my_env
my_env = new 'Env'
ok( my_env, 'Got an .Env pmc' )
my_env['REQUEST_TYPE'] = 'GET'
my_env['QUERY_STRING'] = 'as=df'
query_hash = parse_get_sub()
val = query_hash['as']
is( val, 'df', 'single GET param' )
my_env['QUERY_STRING'] = 'sky=blue;grass=green&water=wet'
query_hash = parse_get_sub()
val = query_hash['sky']
is( val, 'blue', 'first of three GET params' )
val = query_hash['grass']
is( val, 'green', 'second of three GET params' )
val = query_hash['water']
is( val, 'wet', 'third of three GET params' )
my_env['QUERY_STRING'] = 'a=1'
query_hash = parse_get_sub()
val = query_hash['a']
is( val, '1', 'numeric value' )
.end
=head1 AUTHOR
Bernhard Schmalhofer <Bernhard Schmalhofer@gmx.de>
=cut
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: