Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plux committed Apr 24, 2024
1 parent 17284ab commit b0f0f06
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 96 deletions.
6 changes: 1 addition & 5 deletions apps/els_lsp/src/els_document_highlight_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ valid_highlight_pois(Document, Line, Character) ->
P
|| #{kind := Kind} = P <- POIs,
Kind /= keyword_expr,
Kind /= spec,
Kind /= module,
Kind /= function_clause,
Kind /= function,
Kind /= define,
Kind /= callback
Kind /= function_clause
].

%%==============================================================================
Expand Down
174 changes: 83 additions & 91 deletions apps/els_lsp/test/els_code_action_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,23 @@ suggest_variable(Config) ->
},
#{result := Result} = els_client:document_codeaction(Uri, Range, [Diag]),
Expected =
[
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range => Range,
newText => <<"Bar">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Did you mean 'Bar'?">>
}
],
?assertEqual(Expected, Result),
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range => Range,
newText => <<"Bar">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Did you mean 'Bar'?">>
},
?assert(lists:member(Expected, Result)),
ok.

-spec fix_module_name(config()) -> ok.
Expand Down Expand Up @@ -325,30 +323,28 @@ create_undefined_function(Config) ->
},
#{result := Result} = els_client:document_codeaction(Uri, Range, [Diag]),
Expected =
[
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range =>
els_protocol:range(#{
from => {28, 1},
to => {28, 1}
}),
newText =>
<<"foobar() ->\n ok.\n\n">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Create function foobar/0">>
}
],
?assertEqual(Expected, Result),
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range =>
els_protocol:range(#{
from => {28, 1},
to => {28, 1}
}),
newText =>
<<"foobar() ->\n ok.\n\n">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Create function foobar/0">>
},
?assert(lists:member(Expected, Result)),
ok.

-spec create_undefined_function_arity((config())) -> ok.
Expand All @@ -366,30 +362,28 @@ create_undefined_function_arity(Config) ->
},
#{result := Result} = els_client:document_codeaction(Uri, Range, [Diag]),
Expected =
[
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range =>
els_protocol:range(#{
from => {28, 1},
to => {28, 1}
}),
newText =>
<<"foobar(Arg1, Arg2, Arg3) ->\n ok.\n\n">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Create function foobar/3">>
}
],
?assertEqual(Expected, Result),
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range =>
els_protocol:range(#{
from => {28, 1},
to => {28, 1}
}),
newText =>
<<"foobar(Arg1, Arg2, Arg3) ->\n ok.\n\n">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Create function foobar/3">>
},
?assert(lists:member(Expected, Result)),
ok.

-spec create_undefined_function_variable_names((config())) -> ok.
Expand All @@ -407,30 +401,28 @@ create_undefined_function_variable_names(Config) ->
},
#{result := Result} = els_client:document_codeaction(Uri, Range, [Diag]),
Expected =
[
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range =>
els_protocol:range(#{
from => {28, 1},
to => {28, 1}
}),
newText =>
<<"foobar(Foo, FooBar, Bar, FooBar) ->\n ok.\n\n">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Create function foobar/5">>
}
],
?assertEqual(Expected, Result),
#{
edit => #{
changes =>
#{
binary_to_atom(Uri, utf8) =>
[
#{
range =>
els_protocol:range(#{
from => {28, 1},
to => {28, 1}
}),
newText =>
<<"foobar(Foo, FooBar, Bar, FooBar) ->\n ok.\n\n">>
}
]
}
},
kind => <<"quickfix">>,
title => <<"Create function foobar/5">>
},
?assert(lists:member(Expected, Result)),
ok.

-spec fix_callbacks(config()) -> ok.
Expand Down

0 comments on commit b0f0f06

Please sign in to comment.