4 ms·
Ok, I think I might get it now? The tests are written down in the example, but are only run by the package developer and the results are hidden from the user? T
by civilized 4y ago
Ok, I think I might get it now? The tests are written down in the example, but are only run by the package developer and the results are hidden from the user? That seems like a good thing. The user wants to see the example but doesn't care about whether your test passed.
The magic makes sense now too. You already need a roxygen2 header to set up the auto-generated tests, so why not call it @expect and then write equal instead of expect_equal, so as not to repeat yourself?
- masklinn 4y ago> Ok, I think I might get it now? The tests are written down in the example, but are only run by the package developer and the results are hidden from the user? That seems like a good thing. The user wants to see the example but doesn't care about whether your test passed. But surely the user wants to see what the result of the call is, if it's relevant? That's why rust examples (which are also doctests) include the corresponding assertions. You can hide them, but usually you don't, because e.g. showing what the result of `str::len` is is the point of having an example: https://doc.rust-lang.org/std/primitive.str.html#method.len https://doc.rust-lang.org/std/primitive.str.html#method.len Unless roxygen or Rd independently runs the code and embeds the output independent of the doctests succeeding or failing?
- civilized 4y agoRight, the user wants to see the result, but doesn't care about the developer's test that the result is the expected result.