And in ExUnit
test this works correctly too
$ mix test
Compiling 1 file (.ex)
Generated xxx app
.
Finished in 0.03 seconds (0.00s async, 0.03s sync)
1 test, 0 failures
Randomized with seed 488666
$ cat test/xxx_test.exs
defmodule ThrowawayTest do
use ExUnit.Case
{:module, _name, bytecode, _exports} =
defmodule TestModule do
@type my_type() :: :a | :b | :c | :d
def hello, do: 1
end
@bytecode bytecode
test "generates the expected types" do
assert {:ok, [type: {:my_type, _, []}]} = Code.Typespec.fetch_types(@bytecode)
end
end