flatten sclars
[gitmo/Moose-Autobox.git] / t / 008_flatten.t
CommitLineData
30715849 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
e29de5ed 6use Test::More tests => 4;
30715849 7use Moose::Autobox;
8
9my $array = [ qw(1 2 3 4 ) ];
10is_deeply(
11 [ $array->flatten ],
12 [ 1, 2, 3, 4 ],
13 "flattening an array returns a list",
14);
15
16my $hash = { a => 1, b => 2 };
17is_deeply(
18 [ sort $hash->flatten ],
19 [ qw(1 2 a b) ],
20 "flattening a hash returns a list",
21);
e29de5ed 22
23my $scalar = 1;
24is_deeply(
25 [ $scalar->flatten ],
26 [ 1 ],
27 "flattening a scalar returns the scalar",
28);
29
30my $scalar_ref = \$scalar;
31is_deeply(
32 [ $scalar_ref->flatten ],
33 [ \$scalar ],
34 "flattening a reference to a scalar returns the same scalar reference",
35);