Skip to content

Commit

Permalink
First attempt on Elixir location tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smaximov committed Aug 28, 2023
1 parent 10978db commit 567ccf8
Show file tree
Hide file tree
Showing 2 changed files with 2,949 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/elixir_sense/location_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
defmodule ElixirSense.LocationTest do
use ExUnit.Case, async: false

import ElixirSense.Location

setup do
elixir_src = Path.join(File.cwd!(), "/test/misc/mock_elixir_src")
Application.put_env(:elixir_sense, :elixir_src, elixir_src)

on_exit(fn ->
Application.delete_env(:elixir_sense, :elixir_src)
end)
end

describe "find_mod_fun_source/3" do
test "returns location of a core Elixir function" do
assert %ElixirSense.Location{type: :function, line: 2017, column: 3, file: file} =
find_mod_fun_source(String, :length, 1)

assert String.ends_with?(file, "/mock_elixir_src/lib/elixir/lib/string.ex")
end
end

describe "find_type_source/3" do
test "returns location of a core Elixir type" do
assert %ElixirSense.Location{type: :typespec, line: 269, column: 3, file: file} =
find_type_source(String, :t, 0)

assert String.ends_with?(file, "/mock_elixir_src/lib/elixir/lib/string.ex")
end
end
end
Loading

0 comments on commit 567ccf8

Please sign in to comment.