2 use Test::Deep qw(cmp_deeply);
5 use_ok 'SL::Request', qw(flatten unflatten);
7 use constant DEBUG => 0;
10 my $flat = flatten($_[0]);
11 print Dumper($flat) if DEBUG;
13 my $unflat = unflatten($flat);
14 print Dumper($unflat) if DEBUG;
16 cmp_deeply($flat, $_[1], $_[2] . " flatten");
17 cmp_deeply($unflat, $_[0], $_[2] . " unflatten");
29 f { a => { b => 2 } },
32 ], 'simple hash nesting';
40 f { a => [ { c => 1, d => 2 }, { c => 3, d => 4 }, ] },
48 # tests from Hash::Flatten below
79 ], 'Hash::Flatten 2 - weird keys and values';
105 [ 'y[+].baz' => 'bum', ],
106 ], 'Hash::Flatten 3 - mixed';
115 'easily', [ 'parted', 'from' ], 'his'
122 [ 'y[+][]' => 'a', ],
123 [ 'y[][]' => 'fool', ],
125 [ 'y[+][]' => 'easily', ],
126 [ 'y[][+][]' => 'parted', ],
127 [ 'y[][][]' => 'from', ],
128 [ 'y[][]' => 'his', ],
129 [ 'y[]' => 'money', ],
130 ], 'Hash::Flatten 4 - array nesting';
156 [ 'y[+].baz' => 'bum', ],
157 ], 'Hash::Flatten 5 - deep mix';