From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#!perl
use strict;
use Test::More tests => 3;
BEGIN { use_ok('Math::Random::Discrete'); }
my @weights;
my @values = qw/a b c d/;
dies_ok( sub { my $gen = Math::Random::Discrete->( \@weights, \@values ) },
"no weights" );
@weights = (42);
dies_ok( sub { my $gen = Math::Random::Discrete->( \@weights, \@values ) },
"mismatched weights and values" );