diff --git a/apps/language_server/test/providers/execute_command/expand_macro_test.exs b/apps/language_server/test/providers/execute_command/expand_macro_test.exs index a7d81d777..44f5013eb 100644 --- a/apps/language_server/test/providers/execute_command/expand_macro_test.exs +++ b/apps/language_server/test/providers/execute_command/expand_macro_test.exs @@ -144,75 +144,86 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ExpandMacroTest do code = "use Application" result = ExpandMacro.expand_full(buffer, code, 2) - assert result.expand_once =~ - """ - ( - require Application - Application.__using__([]) - ) - """ - |> String.trim() - - assert result.expand =~ - """ - ( - require Application - Application.__using__([]) - ) - """ - |> String.trim() + if Version.match?(System.version(), ">= 1.13.0") do + assert result.expand_once =~ + """ + ( + require Application + Application.__using__([]) + ) + """ + |> String.trim() - assert result.expand_partial =~ - """ - ( - require Application + assert result.expand =~ + """ + ( + require Application + Application.__using__([]) + ) + """ + |> String.trim() + assert result.expand_partial =~ + """ ( - @behaviour Application - @doc false - def stop(_state) do - :ok - end + require Application - defoverridable Application - ) - ) - """ - |> String.trim() + ( + @behaviour Application + @doc false + def stop(_state) do + :ok + end - assert result.expand_all =~ - (if Version.match?(System.version(), ">= 1.14.0") do - """ - ( - require Application + defoverridable Application + ) + ) + """ + |> String.trim() + assert result.expand_all =~ + (if Version.match?(System.version(), ">= 1.14.0") do + """ ( - Module.__put_attribute__(MyModule, :behaviour, Application, nil, []) - Module.__put_attribute__(MyModule, :doc, {0, false}, nil, []) + require Application - def stop(_state) do - :ok - end + ( + Module.__put_attribute__(MyModule, :behaviour, Application, nil, []) + Module.__put_attribute__(MyModule, :doc, {0, false}, nil, []) - Module.make_overridable(MyModule, Application) - """ - else - """ - ( - require Application + def stop(_state) do + :ok + end + Module.make_overridable(MyModule, Application) + """ + else + """ ( - Module.__put_attribute__(MyModule, :behaviour, Application, nil) - Module.__put_attribute__(MyModule, :doc, {0, false}, nil) - - def stop(_state) do - :ok - end - - Module.make_overridable(MyModule, Application) - """ - end) - |> String.trim() + require Application + + ( + Module.__put_attribute__(MyModule, :behaviour, Application, nil) + Module.__put_attribute__(MyModule, :doc, {0, false}, nil) + + def stop(_state) do + :ok + end + + Module.make_overridable(MyModule, Application) + """ + end) + |> String.trim() + else + assert result.expand_once =~ + """ + ( + require(Application) + Application.__using__([]) + ) + """ + |> String.trim() + end end test "with errors" do diff --git a/apps/language_server/test/providers/references/locator_test.exs b/apps/language_server/test/providers/references/locator_test.exs index 4030f9424..1344fb1f9 100644 --- a/apps/language_server/test/providers/references/locator_test.exs +++ b/apps/language_server/test/providers/references/locator_test.exs @@ -455,7 +455,8 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do } ] = references - assert range_1 == %{start: %{line: 90, column: 60}, end: %{line: 90, column: 68}} + assert range_1 == + %{start: %{line: 90, column: 60}, end: %{line: 90, column: 68}} |> maybe_shift end test "find references with cursor over a function with default argument when caller does not uses default arguments", @@ -501,7 +502,8 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do } ] = references - assert range_1 == %{start: %{line: 91, column: 60}, end: %{line: 91, column: 69}} + assert range_1 == + %{start: %{line: 91, column: 60}, end: %{line: 91, column: 69}} |> maybe_shift end test "find references with cursor over a module with funs with default argument", %{ @@ -571,9 +573,9 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do } ] = references - assert read_line("test/support/functions_with_default_args.ex", range_1) == "my_func(1)" + assert read_line("test/support/functions_with_default_args.ex", range_1) =~ "my_func(1)" - assert read_line("test/support/functions_with_default_args.ex", range_2) == + assert read_line("test/support/functions_with_default_args.ex", range_2) =~ "my_func(1, \"a\")" references = Locator.references(buffer, 5, 8, trace) @@ -597,9 +599,9 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do } ] = references - assert read_line("test/support/functions_with_default_args.ex", range_1) == "my_func(1)" + assert read_line("test/support/functions_with_default_args.ex", range_1) =~ "my_func(1)" - assert read_line("test/support/functions_with_default_args.ex", range_2) == + assert read_line("test/support/functions_with_default_args.ex", range_2) =~ "my_func(1, \"a\")" end @@ -635,13 +637,13 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do } ] = references - assert read_line("test/support/functions_with_default_args.ex", range_1) == "my_func()" - assert read_line("test/support/functions_with_default_args.ex", range_2) == "my_func(1)" + assert read_line("test/support/functions_with_default_args.ex", range_1) =~ "my_func()" + assert read_line("test/support/functions_with_default_args.ex", range_2) =~ "my_func(1)" - assert read_line("test/support/functions_with_default_args.ex", range_3) == + assert read_line("test/support/functions_with_default_args.ex", range_3) =~ "my_func(1, \"a\")" - assert read_line("test/support/functions_with_default_args.ex", range_4) == "my_func(1, 2, 3)" + assert read_line("test/support/functions_with_default_args.ex", range_4) =~ "my_func(1, 2, 3)" buffer = """ defmodule Caller do @@ -671,12 +673,12 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do } ] = references - assert read_line("test/support/functions_with_default_args.ex", range_2) == "my_func(1)" + assert read_line("test/support/functions_with_default_args.ex", range_2) =~ "my_func(1)" - assert read_line("test/support/functions_with_default_args.ex", range_3) == + assert read_line("test/support/functions_with_default_args.ex", range_3) =~ "my_func(1, \"a\")" - assert read_line("test/support/functions_with_default_args.ex", range_4) == "my_func(1, 2, 3)" + assert read_line("test/support/functions_with_default_args.ex", range_4) =~ "my_func(1, 2, 3)" buffer = """ defmodule Caller do @@ -700,7 +702,7 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do } ] = references - assert read_line("test/support/functions_with_default_args.ex", range_4) == "my_func(1, 2, 3)" + assert read_line("test/support/functions_with_default_args.ex", range_4) =~ "my_func(1, 2, 3)" buffer = """ defmodule Caller do @@ -1086,23 +1088,22 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do references = Locator.references(buffer, 3, 59, trace) - assert references == [ - %{ - range: - %{end: %{column: 62, line: 3}, start: %{column: 58, line: 3}} |> maybe_shift, - uri: nil - }, - %{ - uri: "test/support/modules_with_references.ex", - range: - %{start: %{line: 65, column: 47}, end: %{line: 65, column: 51}} |> maybe_shift - }, - %{ - range: - %{end: %{column: 13, line: 70}, start: %{column: 9, line: 70}} |> maybe_shift, - uri: "test/support/modules_with_references.ex" - } - ] + if Version.match?(System.version(), ">= 1.13.0") do + assert references == [ + %{ + range: %{end: %{column: 62, line: 3}, start: %{column: 58, line: 3}}, + uri: nil + }, + %{ + uri: "test/support/modules_with_references.ex", + range: %{start: %{line: 65, column: 47}, end: %{line: 65, column: 51}} + }, + %{ + range: %{end: %{column: 13, line: 70}, start: %{column: 9, line: 70}}, + uri: "test/support/modules_with_references.ex" + } + ] + end end test "find references from remote calls with the function in the next line", %{trace: trace} do @@ -1117,20 +1118,22 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do references = Locator.references(buffer, 3, 59, trace) - assert [ - %{ - range: %{end: %{column: 62, line: 3}, start: %{column: 58, line: 3}}, - uri: nil - }, - %{ - range: %{end: %{column: 51, line: 65}, start: %{column: 47, line: 65}}, - uri: "test/support/modules_with_references.ex" - }, - %{ - range: %{end: %{column: 13, line: 70}, start: %{column: 9, line: 70}}, - uri: "test/support/modules_with_references.ex" - } - ] = references + if Version.match?(System.version(), ">= 1.13.0") do + assert [ + %{ + range: %{end: %{column: 62, line: 3}, start: %{column: 58, line: 3}}, + uri: nil + }, + %{ + range: %{end: %{column: 51, line: 65}, start: %{column: 47, line: 65}}, + uri: "test/support/modules_with_references.ex" + }, + %{ + range: %{end: %{column: 13, line: 70}, start: %{column: 9, line: 70}}, + uri: "test/support/modules_with_references.ex" + } + ] = references + end end if Version.match?(System.version(), ">= 1.14.0") do diff --git a/apps/language_server/test/providers/signature_help/signature_test.exs b/apps/language_server/test/providers/signature_help/signature_test.exs index 2934914c8..70074e0c8 100644 --- a/apps/language_server/test/providers/signature_help/signature_test.exs +++ b/apps/language_server/test/providers/signature_help/signature_test.exs @@ -1051,7 +1051,7 @@ defmodule ElixirLS.LanguageServer.Providers.SignatureHelp.SignatureTest do end end - if System.otp_release() |> String.to_integer() >= 23 do + if System.otp_release() |> String.to_integer() >= 25 do test "finds signatures from metadata erlang behaviour call from outside" do code = """ :file_server.init()