-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path07_count_find.t
40 lines (30 loc) · 867 Bytes
/
07_count_find.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
use v6.c;
use Test;
use XML::XPath;
plan 10;
my $x = XML::XPath.new(xml => q:to/ENDXML/);
<AAA>
<CCC><BBB/><BBB/><BBB/></CCC>
<DDD><BBB/><BBB/></DDD>
<EEE><CCC/><DDD/></EEE>
<FFF />
</AAA>
ENDXML
my $set;
$set = $x.find('count(/AAA/*)');
is $set, 4, 'found 3 nodes';
$set = $x.find('count(/AAA/*) = 4');
is $set, True, 'found 3 nodes';
$set = $x.find('count(/AAA/*) = 3');
is $set, False, 'found 3 nodes';
$set = $x.find('//*[ count(BBB) = 2 ]', :to-list(True));
is $set.elems, 1 , 'found one node';
is $set[0].name, 'DDD', 'node name is BBB';
$set = $x.find('//*[ count(*) = 2]');
is $set.elems, 2 , 'found two nodes';
is $set[0].name, 'DDD', 'node name is DDD';
is $set[1].name, 'EEE', 'node name is EEE';
$set = $x.find('//*[ count(*) = 3]', :to-list(True));
is $set.elems, 1 , 'found one node';
is $set[0].name, 'CCC', 'node name is CCC';
done-testing;