Skip to content

Commit

Permalink
fix tests on 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Aug 22, 2024
1 parent b5d01ce commit 2ebafdd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/elixir_sense/core/compiler/macro.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ defmodule ElixirSense.Core.Compiler.Macro do
when is_atom(name) and is_list(args) and is_list(meta) do
arity = length(args)

case Macro.Env.expand_import(env, meta, name, arity, trace: false, check_deprecations: false) do
case NormalizedMacroEnv.expand_import(env, meta, name, arity, trace: false, check_deprecations: false) do
{:macro, _receiver, expander} ->
# TODO register call
# We don't want the line to propagate yet, but generated might!
Expand Down Expand Up @@ -169,7 +169,7 @@ defmodule ElixirSense.Core.Compiler.Macro do
{original, false}

true ->
case Macro.Env.expand_require(env, meta, receiver, name, length(args),
case NormalizedMacroEnv.expand_require(env, meta, receiver, name, length(args),
trace: false,
check_deprecations: false
) do
Expand Down
6 changes: 6 additions & 0 deletions test/elixir_sense/core/compiler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ if true or Version.match?(System.version(), ">= 1.17.0-dev") do
assert_expansion("quote do: &inspect/1")
end

if Version.match?(System.version(), ">= 1.17.0") do
test "expands quote with bind_quoted" do
assert_expansion("""
kv = [a: 1]
Expand All @@ -390,6 +391,7 @@ if true or Version.match?(System.version(), ">= 1.17.0-dev") do
end
""")
end
end

test "expands quote with unquote false" do

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.13.x | Erlang/OTP 24.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.14.x | Erlang/OTP 24.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.15.x | Erlang/OTP 24.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.15.x | Erlang/OTP 26.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.14.x | Erlang/OTP 24.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 24.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.14.x | Erlang/OTP 23.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)

Check failure on line 396 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 23.x)

test special forms expands quote with unquote false (ElixirSense.Core.CompilerTest)
assert_expansion("""
Expand All @@ -399,11 +401,13 @@ if true or Version.match?(System.version(), ">= 1.17.0-dev") do
""")
end

if Version.match?(System.version(), ">= 1.17.0") do
test "expands quote with file" do
assert_expansion("""
quote file: "some.ex", do: bar(1, 2, 3)
""")
end
end

test "expands quote with line" do

Check failure on line 412 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.15.x | Erlang/OTP 24.x)

test special forms expands quote with line (ElixirSense.Core.CompilerTest)

Check failure on line 412 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.14.x | Erlang/OTP 23.x)

test special forms expands quote with line (ElixirSense.Core.CompilerTest)

Check failure on line 412 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.14.x | Erlang/OTP 25.x)

test special forms expands quote with line (ElixirSense.Core.CompilerTest)

Check failure on line 412 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 22.x)

test special forms expands quote with line (ElixirSense.Core.CompilerTest)

Check failure on line 412 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 24.x)

test special forms expands quote with line (ElixirSense.Core.CompilerTest)

Check failure on line 412 in test/elixir_sense/core/compiler_test.exs

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.15.x | Erlang/OTP 24.x)

test special forms expands quote with line (ElixirSense.Core.CompilerTest)
assert_expansion("""
Expand Down Expand Up @@ -445,6 +449,7 @@ if true or Version.match?(System.version(), ">= 1.17.0-dev") do
""")
end

if Version.match?(System.version(), ">= 1.17.0") do
test "expands &" do
assert_expansion("& &1")
assert_expansion("&Enum.take(&1, 5)")
Expand All @@ -458,6 +463,7 @@ if true or Version.match?(System.version(), ">= 1.17.0-dev") do
assert_expansion("&Enum.map(&2, &1)")
assert_expansion("&inspect([&2, &1])")
end
end

test "expands fn" do
assert_expansion("fn -> 1 end")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ defmodule ElixirSense.Core.MetadataBuilder.ErrorRecoveryTest do
assert Enum.any?(env.vars, &(&1.name == :x))
end

if Version.match?(System.version(), ">= 1.17.0") do
test "cursor in left side of catch clause after type" do
code = """
try do
Expand All @@ -452,7 +453,9 @@ defmodule ElixirSense.Core.MetadataBuilder.ErrorRecoveryTest do
assert {meta, env} = get_cursor_env(code)
assert Enum.any?(env.vars, &(&1.name == :x))
end
end

if Version.match?(System.version(), ">= 1.17.0") do
test "cursor in left side of catch clause 2 arg guard" do
code = """
try do
Expand All @@ -464,6 +467,7 @@ defmodule ElixirSense.Core.MetadataBuilder.ErrorRecoveryTest do
assert {meta, env} = get_cursor_env(code)
assert Enum.any?(env.vars, &(&1.name == :x))
end
end

test "cursor in right side of catch clause" do
code = """
Expand Down Expand Up @@ -777,6 +781,7 @@ defmodule ElixirSense.Core.MetadataBuilder.ErrorRecoveryTest do
assert Enum.any?(env.vars, &(&1.name == :y))
end

if Version.match?(System.version(), ">= 1.17.0") do
test "cursor in do block reduce left side of clause too many args" do
code = """
for x <- [], reduce: %{} do
Expand All @@ -788,6 +793,7 @@ defmodule ElixirSense.Core.MetadataBuilder.ErrorRecoveryTest do
# this test fails
# assert Enum.any?(env.vars, &(&1.name == :y))
end
end

test "cursor in do block reduce right side of clause" do
code = """
Expand Down Expand Up @@ -868,6 +874,7 @@ defmodule ElixirSense.Core.MetadataBuilder.ErrorRecoveryTest do
assert Enum.any?(env.vars, &(&1.name == :x))
end

if Version.match?(System.version(), ">= 1.17.0") do
test "incomplete clause left side guard" do
code = """
fn
Expand All @@ -877,6 +884,7 @@ defmodule ElixirSense.Core.MetadataBuilder.ErrorRecoveryTest do
assert {meta, env} = get_cursor_env(code)
assert Enum.any?(env.vars, &(&1.name == :x))
end
end

test "incomplete clause right side" do
code = """
Expand Down
28 changes: 15 additions & 13 deletions test/elixir_sense/core/metadata_builder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3850,8 +3850,10 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
test "map guards" do
assert %VarInfo{name: :x, type: {:map, [], nil}} = var_with_guards("is_map(x)")

if Version.match?(System.version(), ">= 1.17.0") do
assert %VarInfo{name: :x, type: {:map, [], nil}} =
var_with_guards("is_non_struct_map(x)")
end

assert %VarInfo{name: :x, type: {:map, [], nil}} = var_with_guards("map_size(x) == 1")
assert %VarInfo{name: :x, type: {:map, [], nil}} = var_with_guards("1 == map_size(x)")
Expand Down Expand Up @@ -7860,7 +7862,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
kind: :type,
name: :foo,
positions: [{4, 5}],
end_positions: [{4, 28}],
end_positions: _,
generated: [false],
specs: ["@type foo() :: unquote(v())"]
}
Expand Down Expand Up @@ -7894,13 +7896,13 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
|> string_to_state

assert %{
{My, :bar, 0} => %ElixirSense.Core.State.TypeInfo{
name: :bar,
{My, :foo, 0} => %ElixirSense.Core.State.TypeInfo{
name: :foo,
args: [[]],
specs: ["@type bar()"],
specs: ["@type foo"],
kind: :type,
positions: [{3, 3}],
end_positions: [{3, 14}],
positions: [{2, 3}],
end_positions: [{2, 12}],
generated: [false],
doc: "",
meta: %{}
Expand All @@ -7922,7 +7924,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
specs: ["@type baz(a)"],
kind: :type,
positions: [{4, 3}],
end_positions: [{4, 15}],
end_positions: _,
generated: [false],
doc: "",
meta: %{}
Expand Down Expand Up @@ -8040,13 +8042,13 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
|> string_to_state

assert %{
{My, :bar, 0} => %ElixirSense.Core.State.SpecInfo{
name: :bar,
{My, :foo, 0} => %ElixirSense.Core.State.SpecInfo{
name: :foo,
args: [[]],
specs: ["@spec bar()"],
specs: ["@spec foo"],
kind: :spec,
positions: [{3, 3}],
end_positions: [{3, 14}],
positions: [{2, 3}],
end_positions: [{2, 12}],
generated: [false],
doc: "",
meta: %{}
Expand All @@ -8068,7 +8070,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
specs: ["@spec baz(a)"],
kind: :spec,
positions: [{4, 3}],
end_positions: [{4, 15}],
end_positions: _,
generated: [false],
doc: "",
meta: %{}
Expand Down

0 comments on commit 2ebafdd

Please sign in to comment.