-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Support our default inspect notation on doctests #1815
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
Comments
Thinking about it, it seems that working on expresion is good enough. iex> Version.parse("2.0.1-alpha1")
Version.Schema[version: "2.0.1-alpha1"] And let it pattern match. iex> 5 - 3
1 + 1 Seems valid to me. Something I may want to write like that to clarify where the number comes from for instance. |
@JordiPolo Good point. But then it means we shouldn't call it |
Working only on expression is not enough when we want to express more On Sat, Oct 26, 2013 at 5:41 PM, José Valim [email protected]:
Eric Meadows-Jönsson |
Speaking out of turn here (and ignorance), but perhaps you could enable option #3 by "enhancing" the comment syntax, somewhat as Javadoc does, perhaps with a simple doubled-hash: If it starts with two hashmarks, you know it's inspect notation. |
I think 3 is enough, doing so would also kind of enforce the idea of inspecting values that way (which is already pervasive in Elixir). Sincerely I'd also go as far as suggesting adding support for comments limited that way, like Clojure does with something |> something_else(#<"I was here, but let's try the default parameter">) |> keep_going |
It has already been suggested and noted a couple times that doctests do not support the inspect notation. For example, we can't test this:
This is because doctests work on expressions and not inspected values. This means, tests like this would likely pass:
We have a couple solutions to work around this problem:
iex>
bydoc>
(or something similar).#Version.Schema<2.0.1-alpha1>
and such in docs.The issue with 3 is that it is hard to know if it is a comment or the inspected value. We could add a check that checks if the given expression match
%r"\#(\w+\.?)+<"
and then do a match on the inspected value but this means we are adding a special case to how doctests. And it still doesn't solve the fact it does not behave as IEx.It seems to me the ideal would be to mix 1 and 3. Rename it to
doc>
and add support for#Version.Schema
and such.Ideas?
/cc @meh @alco @ericmj @jwarwick
The text was updated successfully, but these errors were encountered: