in reply to Re: 'either or' value unit test case in Test::Simple or Test::More
in thread 'either or' value unit test case in Test::Simple or Test::More
What about an overkill abstract solution?
# is_one_of($val, \@list); sub is_one_of { my $val = shift; my $list = shift; my $test_name = "$val is not one of @$list"; for (@$list) { pass($test_name), return if $val eq $_; } diag "never saw [$val] in [@$list]"; fail($test_name); }
And then palette may say:
is_one_of($var, [ qw(a b) ]);
Update: fixed after grinder's comment — return and diag added.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 'either or' value unit test case in Test::Simple or Test::More
by grinder (Bishop) on Jan 05, 2007 at 16:49 UTC |