Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question:
Suppose I have a set of named conditions which should hold true for each element in a set of data. The conditions may be reasonably complex, like $x->foo < $x->bar * 2; etc. And I'd like to see which of the conditions were not met, for each data element.
Now, there is an obvious although a bit verbose way:
my %failed; if (CONDITION) { $failed{"name"} ++; }; # more checks .... return scalar keys %failed ? \%failed : ();
I believe the same can be done via dispatch tables.
However, I'd like to have a more, um, DWIM-ish way:
my $what_failed = complex_check { check { CONDITION; } "name"; check { CONDITION; } "name"; # .... };
I believe this is reasonably simple to write from scratch, but is there a module that does something similar already?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking multiple named assertions (outside Test::More and co)
by tobyink (Canon) on Aug 18, 2013 at 15:17 UTC | |
by Dallaylaen (Chaplain) on Aug 19, 2013 at 08:47 UTC | |
|
Re: Checking multiple named assertions (outside Test::More and co)
by vsespb (Chaplain) on Aug 18, 2013 at 19:29 UTC | |
by Dallaylaen (Chaplain) on Aug 18, 2013 at 20:49 UTC |