sub note_to_sound { my ($note) = @_; return $notes{$note}; } use Test::More tests => 8; return 1 if caller(); # Done if loaded as a module my $song = make_SoM_song (join ' ', 'a' .. 'g'); my @expected = map{note_to_sound($_)} 'a' .. 'g'; Test::More::is_deeply($song, \@expected, "Notes map correctly to phrases"); my %noteCounts; my $samples = 100000; my $nominal = $samples / 7; ++$noteCounts{random_SoM_note($_)} for 1 .. $samples; Test::More::ok (abs($noteCounts{$_} - $nominal) < 200, "Random distribution of $_: $noteCounts{$_}") for map {note_to_sound($_)} 'a' .. 'g';