line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# DESCRIPTION: Lib for tests |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, |
6
|
|
|
|
|
|
|
#=============================================================================== |
7
|
|
|
|
|
|
|
#$Id$ |
8
|
|
|
|
|
|
|
package Flow::Test; |
9
|
2
|
|
|
2
|
|
51883
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
10
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
11
|
2
|
|
|
2
|
|
10
|
use Test::More; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
10
|
|
12
|
2
|
|
|
2
|
|
2444
|
use Data::Dumper; |
|
2
|
|
|
|
|
23668
|
|
|
2
|
|
|
|
|
970
|
|
13
|
|
|
|
|
|
|
require Exporter; |
14
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
15
|
|
|
|
|
|
|
our @EXPORT = qw(is_deeply_xml); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub xml_ref { |
19
|
0
|
|
|
0
|
0
|
|
my $xml = shift; |
20
|
0
|
|
|
|
|
|
my %tags; |
21
|
|
|
|
|
|
|
#collect tags names; |
22
|
0
|
|
|
|
|
|
map { $tags{$_}++ } $xml =~ m/<(\w+)/gis; |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#make handlers |
24
|
0
|
|
|
|
|
|
our $res; |
25
|
0
|
|
|
|
|
|
for ( keys %tags ) { |
26
|
0
|
|
|
|
|
|
my $name = $_; |
27
|
|
|
|
|
|
|
$tags{$_} = sub { |
28
|
0
|
|
0
|
0
|
|
|
my $attr = shift || {}; |
29
|
0
|
|
|
|
|
|
return $res = { |
30
|
|
|
|
|
|
|
name => $name, |
31
|
|
|
|
|
|
|
attr => $attr, |
32
|
0
|
|
|
|
|
|
content => [ grep { ref $_ } @_ ] |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
my $rd = new XML::Flow:: \$xml; |
37
|
0
|
|
|
|
|
|
$rd->read( \%tags ); |
38
|
0
|
|
|
|
|
|
$res; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_deeply_xml { |
43
|
0
|
|
|
0
|
0
|
|
my ( $got, $exp, @params ) = @_; |
44
|
0
|
0
|
|
|
|
|
unless ( is_deeply xml_ref($got), xml_ref($exp), @params ) { |
45
|
0
|
|
|
|
|
|
diag "got:", "<" x 40; |
46
|
0
|
|
|
|
|
|
diag $got; |
47
|
0
|
|
|
|
|
|
diag "expected:", ">" x 40; |
48
|
0
|
|
|
|
|
|
diag $exp; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|