Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“expected:” and “got:” messages in test output .Str-ify data, that's not entirely right (cmp-ok ‘a’, ‘~~’, /b/) #6411

Open
p6rt opened this issue Jul 25, 2017 · 2 comments

Comments

@p6rt
Copy link

p6rt commented Jul 25, 2017

Migrated from rt.perl.org#131797 (status was 'new')

Searchable as RT131797$

@p6rt
Copy link
Author

p6rt commented Jul 25, 2017

From @AlexDaniel

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.

@p6rt
Copy link
Author

p6rt commented Jul 25, 2017

From @AlexDaniel

".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​:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant