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.


In reply to Re: Use of qr// modifier with Test::More::like by kyle
in thread Use of qr// modifier with Test::More::like by gary.monson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.