File: mode.t

package info (click to toggle)
libstatistics-descriptive-perl 3.0801-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 2,026; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 707 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 4;

use Statistics::Descriptive;

{
    my $stat = Statistics::Descriptive::Full->new();

    $stat->add_data( 1, 10, 100 );

    my $mode = $stat->mode();

    # TEST
    ok( !defined($mode), "No mode for a flat distribution." );

    my $second_mode = $stat->mode();

    # TEST
    ok( !defined($second_mode), "No mode after a second call." );
}

{
    my $stat = Statistics::Descriptive::Full->new();

    $stat->add_data( 1, 5, 5, 5, 10, 19, 19, 30 );

    my $mode = $stat->mode();

    # TEST
    is( $mode, 5, "Mode is 5." );

    my $second_mode = $stat->mode();

    # TEST
    is( $second_mode, 5, "Second call mode is 5." );
}