dice() returns a whole number between 1-6.

In the application we have a function that can return any one of a list of possible values. In our example we have a dice() function that throws the dice. It should return a whole number between 1-6.

examples/perl/t/dice_cmp_ok.t
use strict;
use warnings;

use lib 'lib';
use MyTools;

use Test::More tests => 2 * 4;


for (1..4) {
    my $value = dice();
    cmp_ok $value, '>=', 1, 'bigger than 1';
    cmp_ok $value, '<=', 6, 'smaller than 6';
}


perl examples/perl/t/dice_cmp_ok.t

examples/perl/t/dice_cmp_ok.out
1..8
ok 1 - bigger than 1
ok 2 - smaller than 6
ok 3 - bigger than 1
ok 4 - smaller than 6
ok 5 - bigger than 1
ok 6 - smaller than 6
ok 7 - bigger than 1
ok 8 - smaller than 6

It seems to be ok but we are actually not testing the correct thing. We should check if the result is one of the following values (1, 2, 3, 4, 5, 6)