-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doctest allow int/line-number prefix #9430
base: master
Are you sure you want to change the base?
Conversation
⚠️ nested `case` does not spark joy and RegExp might be a better choice for this feature request! This patch aims to formally begin the discussion here about feature parity between Erlang OTP doctest, and the library of the same name maintained by [williamthome](https://github.com/williamthome/doctest/) Specifically this patch targets `>` vs `1>` syntax for declaring the start of a testable code line or set of lines, ex; **Erlang OTP doctest** ````erlang -doc """ This test is how we do with `erlang/otp` doctests ``` > true. true > totallyOkay. totallyOkay ``` """ woot() -> ok. ```` **williamthome doctest** ````erlang -doc """ This test is how we do with `williamthome/doctest` ```erlang 1> false. false 2> thisIsFine. thisIsFine ``` """ muchJoy() -> ok. ````
CT Test Results 2 files 97 suites 1h 8m 57s ⏱️ Results for commit c23347d. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
Here are some results of manual testing, because I'm not yet smort enough to run only doctests from the CLI;
I still be learning the ways of Erlang, and least-bad practices, so any tips towards reducing future costs to maintenance are very much appreciated! CC: @garazdawi I figured it'd be wise to nudge things specific to OTP parity from |
One of the things I like a lot about doctests is that it adds uniformity to the examples. So I think that I would like it to be very oppionionated about how you write examples. So I would like for the examples to either use Which one do you prefer and why? |
1> shell_docs:test(ModuleToTest, []). |
For compatibility with preexisting 1> State = "World".
2> Greeter = fun(State) -> "Hello " ++ State end.
3> Result = Greeter(State).
"Hello World" At the same time I prefer > true.
true
> false.
false True having both is a more overhead to maintain and parse, and I'm but one opinionated noob ;-) |
I think just the Maybe it would be nice to use @garazdawi Sorry for the off-topic question below: Is it possible for the shell to capture pasted content (
The shell would then print:
It would be nice to have this feature to experiment with copied examples from the documentation. |
case
does not spark joy and RegExp might be a better choice for this feature request!This patch aims to formally begin the discussion here about feature parity between Erlang OTP doctest, and the library of the same name maintained by williamthome
Specifically this patch targets
>
vs1>
syntax for declaring the start of a testable code line or set of lines, ex;Erlang OTP doctest
williamthome doctest