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