You are looking at a very old, but free version of the course. If you are interesed the most recent version, check it out on the Perl Maven site.

6.23. Multiple expected values

Someone asked me this question:

Q: Is it possible instead of is(foo(), 42) to have a fixed set of expected values ?

A: With is there is no such option but you have a number of solutions anyway.

Example 6-16. examples/intro/multiple_choice.t

#!/usr/bin/perl
use strict;
use warnings;

# run this script several times to see the (random) error message

use Test::More tests => 2;

like( foo(), qr/^(23|42|68)$/ );
ok( grep { foo() eq $_ } ( 23, 42, 68 ), "name" );

sub foo {
    return ( ( 23, 42, 68, 100, 200 )[ rand(5) ] );
}
$ perl multiple_choice.t 
not ok 1
#     Failed test (multiple_choice.t at line 4)
#                   '100'
#     doesn't match '(?-xism:^(23|42|68)$)'
not ok 2
#     Failed test (multiple_choice.t at line 5)
1..2
# Looks like you failed 2 tests of 2.

$ perl multiple_choice.t 
ok 1
ok 2
1..2

If you are interested in on-site trainings by the author, please contact me directly.