Skip to content

Commit

Permalink
Adding a regression test for issue #78
Browse files Browse the repository at this point in the history
  • Loading branch information
Qqwy committed Nov 20, 2021
1 parent 8d2b257 commit 9456329
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/type_check/macros_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,20 @@ defmodule TypeCheck.MacrosTest do
end
end)
end

test "Specs for struct types don't truncate fields (regression-test for https://github.com/Qqwy/elixir-type_check/issues/78)" do
defmodule DontTruncate do
use TypeCheck

defstruct name: "Foo", age: 42

@spec! from_map(%{}) :: %__MODULE__{}
def from_map(map) do
struct(__MODULE__, map)
end
end

res = DontTruncate.from_map(%{name: "asdf", age: 33})
assert struct(DontTruncate, %{name: "asdf", age: 33}) == res
end
end

0 comments on commit 9456329

Please sign in to comment.