Sorry for the confusing title, I’m not sure how to convey my issue.
I have a struct/module with custom Inspect protocol implementation that outputs string.
defimpl Inspect, for: GenGraph.Query do
@doc false
@spec insect(GenGraph.Query.t(), %Inspect.Opts{}) :: binary()
def inspect(query, _opts) do
GenGraph.Query.to_cypher(query)
end
end
In my main module, I have a macro that generates GenGraph.Query
, but with the custom Inspect protocol implementation, it should outputs the string representation of the query instead:
## Examples
iex> GenGraph.match p in "Person"
MATCH (p:Person)
However, I got the following exception:
Doctest did not compile, got: (SyntaxError) lib/gen_graph.ex:33: syntax error before: '('
If I try to wrap the expected output with double quotes, the doctest failed:
Doctest failed
code: GenGraph.match p in "Person" === "MATCH (p:Person)"
left: MATCH (p:Person)
right: "MATCH (p:Person)"
My question is: Is this use case supposed?
I read https://hexdocs.pm/ex_unit/ExUnit.DocTest.html#module-opaque-types, but it feels like I’m not really performing a test as all if my expected and actual are doing the same expression, i.e.:
iex> GenGraph.match p in "Person"
GenGraph.match p in "Person"
Of course that would pass, but what’s the point?