Skip to content

Commit

Permalink
Snapshot tests for lists:partition
Browse files Browse the repository at this point in the history
Summary: A collection of snapshot tests for `lists:partition` usages.

Reviewed By: ilya-klyuchnikov

Differential Revision: D61489300

fbshipit-source-id: ce718c19cf4fb81221d9e1535980be93a2b253a6
  • Loading branch information
VLanvin authored and facebook-github-bot committed Aug 20, 2024
1 parent 1ae1007 commit ed89ea0
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 1 deletion.
158 changes: 157 additions & 1 deletion crates/elp/src/resources/test/eqwalizer_tests/check/custom.pretty
Original file line number Diff line number Diff line change
Expand Up @@ -2219,4 +2219,160 @@ See https://fb.me/eqwalizer_errors#incompatible_types
because
'something' is not compatible with 'iodata' | 'list' | 'binary'

156 ERRORS
error: incompatible_types
┌─ check/src/custom.erl:2464:5
2464 │ lists:partition(fun is_atom/1, L).
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ lists:partition(erlang:is_atom/1, L).
Expression has type: {[atom() | number()], [atom() | number()]}
Context expected type: {[atom()], [number()]}

See https://fb.me/eqwalizer_errors#incompatible_types

at tuple index 1:
{[atom() | number()], [atom() | number()]} is not compatible with {[atom()], [number()]}
because
[atom() | number()] is not compatible with [atom()]
because
atom() | number() is not compatible with atom()
because
number() is not compatible with atom()

error: incompatible_types
┌─ check/src/custom.erl:2470:5
2470 │ lists:partition(fun is_number/1, L).
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ lists:partition(erlang:is_number/1, L).
Expression has type: {[atom() | number()], [atom() | number()]}
Context expected type: {[atom()], [number()]}

See https://fb.me/eqwalizer_errors#incompatible_types

at tuple index 1:
{[atom() | number()], [atom() | number()]} is not compatible with {[atom()], [number()]}
because
[atom() | number()] is not compatible with [atom()]
because
atom() | number() is not compatible with atom()
because
number() is not compatible with atom()

error: incompatible_types
┌─ check/src/custom.erl:2476:5
2476 │ lists:partition(fun({_Term, V}) -> is_atom(V) end, L).
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ lists:partition(fun, L).
Expression has type: {[{term(), atom() | number()}], [{term(), atom() | number()}]}
Context expected type: {[{term(), atom()}], [{term(), number()}]}

See https://fb.me/eqwalizer_errors#incompatible_types

at tuple index 1:
{[{term(), atom() | number()}], [{term(), atom() | number()}]} is not compatible with {[{term(), atom()}], [{term(), number()}]}
because
[{term(), atom() | number()}] is not compatible with [{term(), atom()}]
because
at tuple index 2:
{term(), atom() | number()} is not compatible with {term(), atom()}
because
atom() | number() is not compatible with atom()

error: incompatible_types
┌─ check/src/custom.erl:2482:5
2482 │ lists:partition(fun({_Term, V}) -> is_number(V) end, L).
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ lists:partition(fun, L).
Expression has type: {[{term(), atom() | number()}], [{term(), atom() | number()}]}
Context expected type: {[{term(), atom()}], [{term(), number()}]}

See https://fb.me/eqwalizer_errors#incompatible_types

at tuple index 1:
{[{term(), atom() | number()}], [{term(), atom() | number()}]} is not compatible with {[{term(), atom()}], [{term(), number()}]}
because
[{term(), atom() | number()}] is not compatible with [{term(), atom()}]
because
at tuple index 2:
{term(), atom() | number()} is not compatible with {term(), atom()}
because
atom() | number() is not compatible with atom()

error: incompatible_types
┌─ check/src/custom.erl:2488:5
2488 │ lists:partition(fun({_Term, V}) -> is_number(V) end, L).
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ lists:partition(fun, L).
Expression has type: {[atom() | number()], [atom() | number()]}
Context expected type: {[none()], [atom() | number()]}

See https://fb.me/eqwalizer_errors#incompatible_types

at tuple index 1:
{[atom() | number()], [atom() | number()]} is not compatible with {[none()], [atom() | number()]}
because
[atom() | number()] is not compatible with [none()]
because
atom() | number() is not compatible with none()

error: incompatible_types
┌─ check/src/custom.erl:2494:5
2494 │ lists:partition(fun({A, _Term}) -> A =:= a end, L).
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ lists:partition(fun, L).
Expression has type: {[{atom(), term()}], [{atom(), term()}]}
Context expected type: {[{'a', term()}], [{atom(), term()}]}

See https://fb.me/eqwalizer_errors#incompatible_types

at tuple index 1:
{[{atom(), term()}], [{atom(), term()}]} is not compatible with {[{'a', term()}], [{atom(), term()}]}
because
[{atom(), term()}] is not compatible with [{'a', term()}]
because
at tuple index 1:
{atom(), term()} is not compatible with {'a', term()}
because
atom() is not compatible with 'a'

error: incompatible_types
┌─ check/src/custom.erl:2500:5
2500 │ lists:partition(fun({ok, _}) -> true; (_) -> false end, L).
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ lists:partition(fun, L).
Expression has type: {[{'ok', atom()} | {'error', term()}], [{'ok', atom()} | {'error', term()}]}
Context expected type: {[{'ok', atom()}], [{'error', term()}]}

See https://fb.me/eqwalizer_errors#incompatible_types

at tuple index 1:
{[{'ok', atom()} | {'error', term()}], [{'ok', atom()} | {'error', term()}]} is not compatible with {[{'ok', atom()}], [{'error', term()}]}
because
[{'ok', atom()} | {'error', term()}] is not compatible with [{'ok', atom()}]
because
{'ok', atom()} | {'error', term()} is not compatible with {'ok', atom()}
because
at tuple index 1:
{'error', term()} is not compatible with {'ok', atom()}

163 ERRORS
42 changes: 42 additions & 0 deletions test_projects/eqwalizer_tests/check/src/custom.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2456,3 +2456,45 @@ maps_fold_no_merge(M1, M2, B) ->
#{}
),
Res.

-spec lists_partition_rid
(L :: [atom() | number()])
-> {[atom()], [number()]}.
lists_partition_rid(L) ->
lists:partition(fun is_atom/1, L).

-spec lists_partition_rid_neg
(L :: [atom() | number()])
-> {[atom()], [number()]}.
lists_partition_rid_neg(L) ->
lists:partition(fun is_number/1, L).

-spec lists_partition_pred
(L :: [{term(), atom() | number()}])
-> {[{term(), atom()}], [{term(), number()}]}.
lists_partition_pred(L) ->
lists:partition(fun({_Term, V}) -> is_atom(V) end, L).

-spec lists_partition_pred_neg
(L :: [{term(), atom() | number()}])
-> {[{term(), atom()}], [{term(), number()}]}.
lists_partition_pred_neg(L) ->
lists:partition(fun({_Term, V}) -> is_number(V) end, L).

-spec lists_partition_no_match
(L :: [atom() | number()])
-> {[none()], [atom() | number()]}.
lists_partition_no_match(L) ->
lists:partition(fun({_Term, V}) -> is_number(V) end, L).

-spec lists_partition_eq
(L :: [{atom(), term()}])
-> {[{a, term()}], [{atom(), term()}]}.
lists_partition_eq(L) ->
lists:partition(fun({A, _Term}) -> A =:= a end, L).

-spec lists_partition_result
(L :: [{ok, atom()} | {error, term()}])
-> {[{ok, atom()}], [{error, term()}]}.
lists_partition_result(L) ->
lists:partition(fun({ok, _}) -> true; (_) -> false end, L).

0 comments on commit ed89ea0

Please sign in to comment.