aboutsummaryrefslogtreecommitdiff
path: root/t/intervals.t
blob: 8d8c131d6df57b616b54bfcd3d5cf1689e890f49 (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 => 1;

use List::Breakdown 'breakdown';

our $VERSION = '0.26';

## no critic (ProhibitMagicNumbers,ProhibitLeadingZeros)
my @numbers = ( 1, 32, 3718.4, 0x56, 0777, 3.14, -5, 1.2e5 );
my $filters = {
    negative => [ undef, 0 ],
    positive => {
        small  => [ 0,   10 ],
        medium => [ 10,  100 ],
        large  => [ 100, undef ],
    },
};
my %filtered = breakdown $filters, @numbers;

my %expected = (
    negative => [ -5, ],
    positive => {
        large  => [ 3_718.4, 511, 120_000, ],
        medium => [ 32,      86, ],
        small  => [ 1,       3.14, ],
    },
);

is_deeply( \%filtered, \%expected, 'intervals' );