-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #74 (Date and DateTime accepting any map)
- Implements fix - Adds regression test - Updates changelog/version
- Loading branch information
Showing
4 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule TypeCheck.Builtin.FixedMapTest do | ||
use ExUnit.Case, async: true | ||
use TypeCheck | ||
|
||
defmodule UnrelatedStruct do | ||
defstruct [] | ||
end | ||
|
||
# Regression test for issue #74 | ||
test "Date.t() only accepts valid dates" do | ||
fun = &TypeCheck.conforms(&1, Date.t()) | ||
|
||
|
||
assert {:ok, _} = fun.(Date.utc_today()) | ||
|
||
assert {:error, _} = fun.(DateTime.utc_now()) | ||
assert {:error, _} = fun.(%{}) | ||
assert {:error, _} = fun.(%UnrelatedStruct{}) | ||
|
||
assert {:error, _} = fun.([]) | ||
assert {:error, _} = fun.(6) | ||
assert {:error, _} = fun.("some string") | ||
end | ||
|
||
end |