Skip Menu |
Report information
Id: 131797
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: alex.jakimenko [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: “expected:” and “got:” messages in test output .Str-ify data, that's not entirely right (cmp-ok ‘a’, ‘~~’, /b/)
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.
".gist" is probably the wrong answer in this case.

my @got = ‘one’, ‘two three’; say @got # OUTPUT: [one two three]

↑ Not very useful

On 2017-07-25 12:52:25, alex.jakimenko@gmail.com wrote:
Show quoted text
> 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.




This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org