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 f { a => [ { a => 1, b => 2 }, { a => 3, c => 4 }, ] },
 
  54 ], 'array of hashes with not existing keys';
 
  57 # tests from Hash::Flatten below
 
  88 ], 'Hash::Flatten 2 - weird keys and values';
 
 114   [ 'y[+].baz' => 'bum',  ],
 
 115 ], 'Hash::Flatten 3 - mixed';
 
 124       'easily', [ 'parted', 'from' ], 'his'
 
 131  [ 'y[+][]'   => 'a',      ],
 
 132  [ 'y[][]'    => 'fool',   ],
 
 134  [ 'y[+][]'   => 'easily', ],
 
 135  [ 'y[][+][]' => 'parted', ],
 
 136  [ 'y[][][]'  => 'from',   ],
 
 137  [ 'y[][]'    => 'his',    ],
 
 138  [ 'y[]'      => 'money',  ],
 
 139 ], 'Hash::Flatten 4 - array nesting';
 
 165   [ 'y[+].baz' => 'bum', ],
 
 166 ], 'Hash::Flatten 5 - deep mix';