News for hackers. Stuff that matters.
Re:Rust 1.48 by steveklabnik on Thursday November 19, 2020 @12:21PM (#25151767)
What is the distinction between a "real" test and a doc test that you're making? At least in Rust, they are the same thing.
Re:Rust 1.48 by masklinn on Thursday November 19, 2020 @01:08PM (#25152338)
I'd guess their coworkers decided to write all tests as doctests, rather than use doctests to ensure examples run fine?

Python's doctests are also formatted and in some ways behaving like an interactive shell session, with

    >>> code here
    output here
rather than just "literate code" so the execution context is a bit strange. This makes complicated doctests hard to inspect and debug. Doubly so because there's almost no tooling which understands doctests.

And of course on the flip side the best tests make for absolutely terrible examples since they try to exercise weird corner cases.

Re:Rust 1.48 by sitkack on Thursday November 19, 2020 @11:08PM (#25157219)
Yes, this. I don't disagree in theory, I disagree in practice.
Re:Rust 1.48 by jedbrown on Thursday November 19, 2020 @05:02PM (#25154889)
I think it's between a test written inside a comment (where smart IDE features don't apply) versus `#[test]` in normal code, where you have a rich editing environment and instant feedback (including `cargo build` failing immediately on errors).

Perhaps it's just my perception, but doctests (in comments) seem slower to run.

Re:Rust 1.48 by steveklabnik on Thursday November 19, 2020 @05:08PM (#25154949)
Ah; rust-analyzer syntax highlights doc tests (though not perfectly), but the higher order bit of "IDE features don't work as well" makes tons of sense, thanks!
Re:Rust 1.48 by sitkack on Thursday November 19, 2020 @11:10PM (#25157230)
This is also part of my complaint. At least in Python, doctests limit the ability for the IDE to be effective.

They hinder the writer as well as the consumer, since they make it harder to write effective tests. What I am saying is, that all tests should be first class wrt the documentation.