Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Unit test failing but "got" and "expected" are equal

by Corion (Pope)
on Jan 04, 2019 at 20:09 UTC ( #1228045=note: print w/replies, xml ) Need Help??


in reply to Unit test failing but "got" and "expected" are equal

Most likely you're getting tripped up by (weirdo?) whitespace or other stuff that renders identical in the terminal.

To better diagnose that, I would dump the output on failure in a way that makes the differences spottable:

my $res = $s->gets(13); if( !is $res, "hello, world!", "puts() and gets() ok") { (my $s = $res) =~ s!([^\w])!sprintf '\\x%02x', ord($1)!ge; diag $s; ($s = "hello, world!") =~ s!([^\w])!sprintf '\\x%02x', ord($1)!ge; diag $s; };

Replies are listed 'Best First'.
Re^2: Unit test failing but "got" and "expected" are equal
by stevieb (Canon) on Jan 04, 2019 at 20:11 UTC

    Good call, thanks Corion!

    # hello\x2c\x20world\x21\x0f # hello\x2c\x20world\x21

    At least now I have something to focus on.

    Update: In the meantime until I can figure out exactly what's going on, I've made the following change to the test so that my automation doesn't keep yelling at me:

    like $s->gets(13), qr/^hello, world!/, "puts() and gets() ok";
      qr/^hello, world!/

      You might also consider  qr/^hello, world!\s*\z/ since  \x0f is a member of the  \s set and the quoted regex allows anything at the end of the string. No! I was thinking of  \f (form feed) and not of  \x0f ... never mind ...


      Give a man a fish:  <%-{-{-{-<

        Don't feel bad, at first, I was thinking the same thing :)

        Because I just reloaded all of my Pi devices from scratch, I'm unsure if this is an "issue" with the config of the serial device on-board or not quite yet. All I know is that after I built my PCB hard-soldered test platform with all my ICs and sensors I'm testing, but before the OS upgrade, it worked without hiccup.

        No software changes to the serial code on my end (or my underlying C code), so I'm thinking it has to be how the device is configured hardware-wise.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1228045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2019-12-13 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?