1use Test::More; 2use strict; use warnings FATAL => 'all'; 3 4use List::Objects::WithUtils 'array'; 5 6is_deeply 7 [ array->flatten_all ], 8 [ ], 9 'empty array flatten_all ok'; 10 11my $arr = array( 1, 2, [ 3, 4, [ 5, 6 ], 7 ] ); 12is_deeply 13 [ $arr->flatten_all ], 14 [ 1, 2, 3, 4, 5, 6, 7 ], 15 'flatten_all on refs ok'; 16 17$arr = array( 1, 2, array(3, 4, array(5, 6) ), 7 ); 18is_deeply 19 [ $arr->flatten_all ], 20 [ 1, 2, 3, 4, 5, 6, 7 ], 21 'flatten_all on objs ok'; 22 23{ package My::ArrayType; 24 use strict; use warnings FATAL => 'all'; 25 sub new { bless [1], shift } 26} 27 28my $foo = My::ArrayType->new; 29$arr = array( 30 array(1, 2, 3), 31 $foo, 32 [ 4, 5, 6 ], 33); 34 35is_deeply 36 [ $arr->flatten_all ], 37 [ 1, 2, 3, $foo, 4, 5, 6 ], 38 'flatten_all skipped ARRAY-type obj ok'; 39 40done_testing; 41