line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
843
|
use Test; |
|
1
|
|
|
|
|
4043
|
|
|
1
|
|
|
|
|
118
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
3
|
BEGIN { plan tests => 11 } |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2599
|
use HTML::FormWizard; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2250
|
|
8
|
1
|
|
|
|
|
11
|
my $form=HTML::FormWizard->new(); |
9
|
1
|
|
|
|
|
5
|
ok(1); |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
574
|
my $x=q/ |
12
|
|
|
|
|
|
|
package Form::TestCGI; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my $y={}; |
16
|
|
|
|
|
|
|
$y->{prints}=0; |
17
|
|
|
|
|
|
|
bless $y; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub print { |
21
|
|
|
|
|
|
|
my $self=shift; |
22
|
|
|
|
|
|
|
$self->{prints}++; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub param { |
26
|
|
|
|
|
|
|
my $self=shift; |
27
|
|
|
|
|
|
|
my $param=shift; |
28
|
|
|
|
|
|
|
if ($param) { |
29
|
|
|
|
|
|
|
return defined($self->{params}->{$param})?($self->{params}->{$param}):(); |
30
|
|
|
|
|
|
|
} else { |
31
|
|
|
|
|
|
|
return scalar keys %{$self->{params}}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
/; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
3
|
my $cgi; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
2
|
$x .= " |
41
|
|
|
|
|
|
|
package __PACKAGE__; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
\$cgi=Form::TestCGI->new(); |
44
|
|
|
|
|
|
|
"; |
45
|
|
|
|
|
|
|
|
46
|
1
|
100
|
|
1
|
|
215
|
eval $x; |
|
1
|
100
|
|
15
|
|
2
|
|
|
1
|
|
|
5
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
|
15
|
|
|
|
|
22
|
|
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
29
|
|
|
8
|
|
|
|
|
36
|
|
|
7
|
|
|
|
|
7
|
|
|
7
|
|
|
|
|
56
|
|
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
22
|
|
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
5
|
if ($@) { |
49
|
0
|
|
|
|
|
0
|
print $@; |
50
|
0
|
|
|
|
|
0
|
ok(0); |
51
|
|
|
|
|
|
|
} else { |
52
|
1
|
|
|
|
|
3
|
ok(1); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
303
|
$form->run(); |
56
|
1
|
|
|
|
|
36
|
ok(0,$cgi->{prints}); |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
112
|
$form->set(-cgi=>$cgi); |
59
|
1
|
|
|
|
|
6
|
$form->run(); |
60
|
1
|
|
|
|
|
5
|
ok(1,$cgi->{prints}); |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
44
|
$cgi->{params}->{teste}=""; |
63
|
1
|
|
|
|
|
5
|
$form->run(); |
64
|
1
|
|
|
|
|
4
|
ok(1,$cgi->{prints}); |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
48
|
$form->add( |
67
|
|
|
|
|
|
|
{ name => 'zbr', |
68
|
|
|
|
|
|
|
needed => 1 |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
4
|
$form->run(); |
73
|
1
|
|
|
|
|
5
|
ok(2,$cgi->{prints}); |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
639
|
$cgi->{params}->{zbr}=""; |
76
|
1
|
|
|
|
|
7
|
$form->run(); |
77
|
1
|
|
|
|
|
15
|
ok(3,$cgi->{prints}); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
429
|
$cgi->{params}->{zbr}="zpto"; |
80
|
1
|
|
|
|
|
5
|
ok(3,$cgi->{prints}); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$form->add( |
83
|
|
|
|
|
|
|
{ name => 'numaro', |
84
|
|
|
|
|
|
|
validate => sub { |
85
|
3
|
|
|
3
|
|
5
|
my $zbr=shift; |
86
|
3
|
100
|
|
|
|
15
|
if ($zbr =~ /^\d+$/) { |
87
|
1
|
|
|
|
|
4
|
return 0; |
88
|
|
|
|
|
|
|
} else { |
89
|
2
|
|
|
|
|
6
|
return "Não é numaro"; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
1
|
|
|
|
|
425
|
); |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
16
|
$form->run(); |
96
|
1
|
|
|
|
|
10
|
ok(4,$cgi->{prints}); |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
357
|
$cgi->{params}->{numaro}="xpto"; |
99
|
1
|
|
|
|
|
5
|
$form->run(); |
100
|
1
|
|
|
|
|
4
|
ok(5,$cgi->{prints}); |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
419
|
$cgi->{params}->{numaro}="1234"; |
103
|
1
|
|
|
|
|
6
|
$form->run(); |
104
|
1
|
|
|
|
|
6
|
ok(5,$cgi->{prints}); |