File: cyclic_structures.t

package info (click to toggle)
libdata-dpath-perl 0.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,328 kB
  • sloc: perl: 3,737; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (5)
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
#! /usr/bin/env perl

use strict;
use warnings;

use Test::More tests => 2;
use Test::Deep;
use Data::DPath 'dpath';
use Data::Dumper;

# local $Data::DPath::DEBUG = 1;

my $data = {};

$data->{AAA} = { BBB   => { CCC  => [ qw/ XXX YYY ZZZ / ] },
                 RRR   => { CCC  => [ qw/ RR1 RR2 RR3 / ] },
                 DDD   => { EEE  => [ qw/ uuu vvv www / ] },
               };
$data->{point} = { to => { ourself => $data } };

my @resultlist;
my $resultlist;
my $context;

# trivial matching

@resultlist = dpath('/AAA/BBB/CCC')->match($data);
cmp_bag(\@resultlist, [ ['XXX', 'YYY', 'ZZZ'] ], "ROOT + KEYs in cyclic structure" );

SKIP:
{
        skip "No recursion detection yet.", 1;
        @resultlist = dpath('//AAA/BBB/CCC')->match($data);
        cmp_bag(\@resultlist, [ ['XXX', 'YYY', 'ZZZ'] ], "ANYWHERE + KEYs in cyclic structure" );
}