Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by Corion (Patriarch)
on Jan 04, 2019 at 20:09 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-23 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found