diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-03-03 08:30:16 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-03-05 20:26:07 +0000 |
commit | 0973e8e6048d1899077f7c2ea4b16995516bf10e (patch) | |
tree | c6a722b4d10c2083ecfbcbde0527ab4aded0e34d /t/test.pl | |
parent | 76895e89c1e609b1a740ae887e6bcf7ece9d4222 (diff) | |
download | perl-0973e8e6048d1899077f7c2ea4b16995516bf10e.tar.gz |
In test.pl, change like() and unlike() to avoid copying the tested scalar.
This means that side effects of matching regexps on it are maintained,
specifically the value of pos, making test.pl more useful for tests in t/re.
This is a subtle divergence from the behaviour of Test::More::{like,unlike}
Diffstat (limited to 't/test.pl')
-rw-r--r-- | t/test.pl | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -325,12 +325,12 @@ sub like ($$@) { like_yn (0,@_) }; # 0 for - sub unlike ($$@) { like_yn (1,@_) }; # 1 for un- sub like_yn ($$$@) { - my ($flip, $got, $expected, $name, @mess) = @_; + my ($flip, undef, $expected, $name, @mess) = @_; my $pass; - $pass = $got =~ /$expected/ if !$flip; - $pass = $got !~ /$expected/ if $flip; + $pass = $_[1] =~ /$expected/ if !$flip; + $pass = $_[1] !~ /$expected/ if $flip; unless ($pass) { - unshift(@mess, "# got '$got'\n", + unshift(@mess, "# got '$_[1]'\n", $flip ? "# expected !~ /$expected/\n" : "# expected /$expected/\n"); } |