19
lorentz
75d

Debugging an assertion for hours that keeps failing on 19 == 20 , and you just cannot figure out why it returns 20, until you realize that it in fact returns 19 and the constant in the test case that you screwed up at the start reads 20.

Comments
  • 2
    What language?

    When I use assertions in pytest (Python) and they fail, it tells me what each value in the condition was derived from.
  • 0
    @lungdart Rust. I definitely would've appreciated just then if assert macros printed their input alongside the error.
  • 1
    https://doc.rust-lang.org/std/...

    Looks like you can do it by passing a string to the format parameter. It might be more verbose, but I'm sure you could wrap it if it's a frequently used pattern
  • 0
    @lungdart I use the message a lot, I just don't tend to repeat the values in it unless I'm debugging a specific assert.
  • 1
    @lorentz speaking of a debugger, can you use one? If you get inspection at the assert, you can trace it back much faster then printing meta data, compiling, Ave rerunning
  • 0
    @lungdart I used to use them a lot but I kinda stopped because trying to persist the probe through event-driven JavaScript was more difficult than it was helpful. I guess I should re-learn them.
  • 0
    Lmao what kind shit is this
Add Comment