@@ -4041,6 +4041,24 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
4041
4041
"""
4042
4042
end
4043
4043
4044
+ test "params with default args" do
4045
+ buffer = """
4046
+ ElixirSenseExample.ModuleWithTypespecs.Local.fun_with_default()
4047
+ """
4048
+
4049
+ list = Suggestion . suggestions ( buffer , 1 , 63 )
4050
+ assert [ % { name: "bar" } , % { name: "foo" } ] = list |> Enum . filter ( & ( & 1 . type == :param_option ) )
4051
+ end
4052
+
4053
+ test "params with multiple specs" do
4054
+ buffer = """
4055
+ ElixirSenseExample.ModuleWithTypespecs.Local.fun_with_multiple_specs()
4056
+ """
4057
+
4058
+ list = Suggestion . suggestions ( buffer , 1 , 70 )
4059
+ assert [ % { name: "opt_name" } ] = list |> Enum . filter ( & ( & 1 . type == :param_option ) )
4060
+ end
4061
+
4044
4062
test "metadata params" do
4045
4063
buffer = """
4046
4064
defmodule Foo do
@@ -4056,6 +4074,39 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
4056
4074
list = Suggestion . suggestions ( buffer , 6 , 10 )
4057
4075
assert [ % { name: "bar" } , % { name: "foo" } ] = list |> Enum . filter ( & ( & 1 . type == :param_option ) )
4058
4076
end
4077
+
4078
+ test "metadata params multiple specs" do
4079
+ buffer = """
4080
+ defmodule Foo do
4081
+ @spec some([{:foo, integer()} | {:bar, String.t()}]) :: :ok
4082
+ @spec some(nil) :: :ok
4083
+ def some(options), do: :ok
4084
+
4085
+ def go do
4086
+ some()
4087
+ end
4088
+ end
4089
+ """
4090
+
4091
+ list = Suggestion . suggestions ( buffer , 7 , 10 )
4092
+ assert [ % { name: "bar" } , % { name: "foo" } ] = list |> Enum . filter ( & ( & 1 . type == :param_option ) )
4093
+ end
4094
+
4095
+ test "metadata params with default args" do
4096
+ buffer = """
4097
+ defmodule Foo do
4098
+ @spec some(atom, [{:foo, integer()} | {:bar, String.t()}]) :: :ok
4099
+ def some(a \\ \\ nil, options), do: :ok
4100
+
4101
+ def go do
4102
+ some()
4103
+ end
4104
+ end
4105
+ """
4106
+
4107
+ list = Suggestion . suggestions ( buffer , 6 , 10 )
4108
+ assert [ % { name: "bar" } , % { name: "foo" } ] = list |> Enum . filter ( & ( & 1 . type == :param_option ) )
4109
+ end
4059
4110
end
4060
4111
4061
4112
describe "suggestions for typespecs" do
0 commit comments