in reply to Use of qr// modifier with Test::More::like
I'm not sure this has anything to do with Test::More.
use Test::More 'tests' => 7; # all tests pass my $string = "abc\ndef\nghi"; my $pattern = qr/def/; my $pattern_m = qr/^def$/m; ok( $string =~ /^def$/m, 'literal/m pattern matches' ); ok( $string =~ $pattern, 'plain qr stored pattern matches' ); is( "$pattern_m", '(?m-xis:^def$)', 'qr/m as string: (?m-xis:^def$)'); like( $string, '/(?m-xis:^def$)/', 'string (?m-xis:^def$) matches' ); ok( $string =~ /(?m-xis:^def$)/, 'literal (?m-xis:^def$) matches'); ok( ! ($string =~ $pattern_m), 'qr/m stored pattern does not match' ); unlike( $string, $pattern_m, 'qr/m stored pattern not "like"' );
Perhaps I've done something foolish here (using Test::More to check Test::More, maybe), but this looks like a bug.
Update after gary.monson's reply: Sorry I wasn't clear. This looks to me like a bug in perl. Without running it, I would have expected the last two tests to come out the opposite of how they did. I originally thought the OP's behavior might have to do with how Test::Builder uses string eval to do its comparison, but that doesn't seem to be the case.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use of qr// modifier with Test::More::like
by gary.monson (Novice) on Mar 27, 2008 at 02:30 UTC |