Given a file point.ex containing:
defmodule Point do
import Record
defrecord :point, [:x, :y]
end
You can get information about the point record macro from the docs chunk:
# iex -S mix
iex> Code.fetch_docs(Point)
{:docs_v1, 2, :elixir, "text/markdown", :hidden,
%{behaviours: [], source_annos: [{1, 1}], source_path: ~c"/home/zacha/dev/libs/mneme/lib/point.ex"},
[
{{:macro, :point, 1}, [generated: true, location: 5], ["point(args \\\\ [])"], :none,
%{record: {:point, [x: nil, y: nil]}, source_annos: [5], defaults: 1}},
{{:macro, :point, 2}, [generated: true, location: 5], ["point(record, args)"], :none,
%{source_annos: [5]}}
]}
This information combined with the macro environment could be used to potentially generate patterns using record syntax:
defmodule PointTest do
use ExUnit.Case
use Mneme
import Point
test "add/2" do
auto_assert point(x: 5, y: 5) <- Point.add(point(x: 1, y: 4), point(x: 4, y: 1))
end
end
(Note that this auto-assert would currently succeed, but when the asserted value changed, Mneme would only offer tuple suggestions.)
Given a file
point.excontaining:You can get information about the
pointrecord macro from the docs chunk:This information combined with the macro environment could be used to potentially generate patterns using record syntax:
(Note that this auto-assert would currently succeed, but when the asserted value changed, Mneme would only offer tuple suggestions.)