Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question:
Hello dear esteemed monks!
I'm looking for a way to test multiple lines to match corresponding regular expressions:
multi_like \@array, [ qr/regex1/, qr/regex2/, .... ], "Test name";
Now obviously I can do it with a subtest and like statements, plus one test for length:
subtest "All lines are like expected" => sub { like $array[0], qr/regex1/; like $array[1], qr/regex2/; .... is scalar @array, $nnn, "No extra lines"; };
And I can do it with one go with Test::Deep, although I haven't yet found out how to make it report the full difference and not just the first mismatch.
But maybe there's a module that does exactly that (matches a list of strings against a list of regexps)?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test:: to match multiple lines against corresponding regular expressions
by haukex (Archbishop) on Jun 24, 2018 at 12:11 UTC | |
|
Re: Test:: to match multiple lines against corresponding regular expressions
by choroba (Cardinal) on Jun 24, 2018 at 17:13 UTC | |
by Dallaylaen (Chaplain) on Jun 26, 2018 at 15:28 UTC |