aboutsummaryrefslogtreecommitdiff
path: root/t/errors.t
blob: 6d9da05fb0d85c1d515c1d9fda713e8b8a19b76d (plain) (blame)
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
#!perl -T

use strict;
use warnings;
use utf8;

use Test::More tests => 7;

use List::Breakdown 'breakdown';

our $VERSION = '0.19';

my @t = 1 .. 3;

# The wrong kind of reference as a spec is fatal
is( eval { breakdown [ a => 'a' ], @t } || undef,
    undef, 'error_wrongref_spec' );

# An undefined value in spec hashref is fatal
is( eval { breakdown { a => undef }, @t } || undef,
    undef, 'error_notref_undef' );

# A non-reference value in spec hashref is fatal
is( eval { breakdown { a => 'a' }, @t } || undef, undef, 'error_notref_def' );

# Any number of items in the numeric range shortcut besides 2 is fatal
is( eval { breakdown { a => [] },  @t } || undef, undef, 'error_badref_array' );
is( eval { breakdown { a => [1] }, @t } || undef, undef, 'error_badref_array' );
is( eval { breakdown { a => [ 1, 2, 3 ] }, @t } || undef,
    undef, 'error_badref_array' );

# A double reference as a value in a spec hashref is fatal
is( eval { breakdown { a => \{} }, @t } || undef, undef,
    'error_badref_double' );