Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few test cases #557

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/known_problems/should_pass/elixir_list_first.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-module(elixir_list_first).

-export([f/0]).

% This is how List.first/1 is defined in Elixir
-spec first([]) -> nil;
([Elem, ...]) -> Elem.
first([]) -> nil;
first([Element | _]) -> Element.

-spec f() -> ok.
f() ->
first(some_list()),
ok.

-spec some_list() -> list().
some_list() -> [anything].
13 changes: 13 additions & 0 deletions test/known_problems/should_pass/refine_comparison_should_pass.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-module(refine_comparison_should_pass).

-export([comp_map_value3/1]).

-type my_map() :: #{value := integer() | nil}.

-spec comp_map_value3(my_map()) -> integer().
comp_map_value3(State) when map_get(value, State) /= nil ->
case State of
#{value := Val} ->
Val + 1
end;
comp_map_value3(#{value := nil}) -> 0.
17 changes: 17 additions & 0 deletions test/should_pass/refine_comparison.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,20 @@ compatom1(_) -> ok.
-spec compatom2(a | b | c | pid()) -> a | c | pid().
compatom2(X) when X =/= b -> X;
compatom2(_) -> a.

-spec compatom3(a | b | c | pid()) -> a | c | pid().
compatom3(X) when X /= b -> X;
compatom3(_) -> a.

-type my_map() :: #{value := integer() | nil}.

-spec comp_map_value1(my_map()) -> integer().
comp_map_value1(State) when map_get(value, State) /= nil ->
Val = map_get(value, State),
Val + 1;
comp_map_value1(#{value := nil}) -> 0.

-spec comp_map_value2(my_map()) -> integer().
comp_map_value2(#{value := Val}) when Val /= nil ->
Val + 1;
comp_map_value2(#{value := nil}) -> 0.
Loading