# New Ticket Created by  Aleks-Daniel Jakimenko-Aleksejev 
# Please include the string:  [perl #131797]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131797 >


Sometimes it is useful to test the input against regexes. Let's try:

Code:
use Test;
cmp-ok ‘foo’, ‘~~’, /bar/, ‘Lorem ipsum.’

Result:
not ok 1 - Lorem ipsum.

# Failed test 'Lorem ipsum.'
# at -e line 2
Regex object coerced to string (please use .gist or .perl to do that)
  in sub cmp-ok at /home/…/…/C712FE6969F786C9380D643DF17E85D06868219E (Test) 
line 243
# expected: ''
#  matcher: 'infix:<~~>'
#      got: 'foo'


It “works”, but it attempts to turn a regex into a Str.

The problem is here: 
https://github.com/rakudo/rakudo/blob/90a0f2e09ef7a74bfb5a8295fa2737f22bd4e07f/lib/Test.pm6#L245-L247

“.gist” should work better in this case, but I'm not sure if it will affect the 
output significantly in other cases…


IRC discussion: https://irclog.perlgeek.de/perl6/2017-07-25#i_14920983


I'm using regexes a lot for whateverable tests (e.g. 
https://github.com/perl6/whateverable/blob/0301ef4bd2e88536b775db219d19084c092e24ca/t/evalable.t#L84-L88
 ). Currently it is doing something completely different underneath (due to 
now-fixed RT #129192), I wanted to change it to regular cmp-ok.

Reply via email to