diff options
author | Ævar Arnfjörð Bjarmason <avar@cpan.org> | 2014-06-21 17:44:20 +0000 |
---|---|---|
committer | Ævar Arnfjörð Bjarmason <avar@cpan.org> | 2014-06-21 17:58:43 +0000 |
commit | aaa63daea7f8ece57d84d8329754f95ea107301e (patch) | |
tree | 2723b291b86bd26f2190f99be6858157f2e08af1 /t/test.pl | |
parent | 43d7f0da895d00d0f557ad72549ddb3194763b55 (diff) | |
download | perl-aaa63daea7f8ece57d84d8329754f95ea107301e.tar.gz |
Make like() and unlike() in t/test.pl refuse non-qr// arguments
As I noted in v5.21.1-12-g826af13 we have subtle bugs in the test suite
because you can do e.g. like($@, '') now which'll be a passing test even
when we have an error, because $@ =~ // will be true.
I'm just changing t/test.pl to not accept non-Regexp arguments, and
fixing up a bunch of test failures that resulted from that. There might
still be more of these in tests that I'm just not running, I've also
changed some of these from $str =~ /foo/ to $str eq 'foo'
(i.e. s/like/is/) in cases where that appeared to work, but it might
break some systems.
Let's just find that out via the smokers.
Diffstat (limited to 't/test.pl')
-rw-r--r-- | t/test.pl | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -420,6 +420,14 @@ sub unlike ($$@) { like_yn (1,@_) }; # 1 for un- sub like_yn ($$$@) { my ($flip, undef, $expected, $name, @mess) = @_; + + # We just accept like(..., qr/.../), not like(..., '...'), and + # definitely not like(..., '/.../') like + # Test::Builder::maybe_regex() does. + unless (re::is_regexp($expected)) { + die "PANIC: The value '$expected' isn't a regexp. The like() function needs a qr// pattern, not a string"; + } + my $pass; $pass = $_[1] =~ /$expected/ if !$flip; $pass = $_[1] !~ /$expected/ if $flip; |