-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathutils_test.exs
More file actions
78 lines (66 loc) · 3.16 KB
/
Copy pathutils_test.exs
File metadata and controls
78 lines (66 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
defmodule ElixirLS.DebugAdapter.UtilsTest do
use ExUnit.Case, async: true
alias ElixirLS.DebugAdapter.Utils
describe "parse_mfa" do
test "elixir" do
assert {:ok, {Some.Module, :fun, 2}} == Utils.parse_mfa("Some.Module.fun/2")
assert {:ok, {Some.Module, :fun, 2}} == Utils.parse_mfa("Elixir.Some.Module.fun/2")
assert {:ok, {Some.Module, :fun, 2}} == Utils.parse_mfa(":'Elixir.Some.Module'.fun/2")
assert {:ok, {Elixir, :fun, 2}} == Utils.parse_mfa("Elixir.fun/2")
assert {:ok, {Elixir.Elixir, :fun, 2}} == Utils.parse_mfa("Elixir.Elixir.fun/2")
end
test "erlang" do
assert {:ok, {:some_module, :fun, 2}} == Utils.parse_mfa(":some_module.fun/2")
assert {:ok, {:"Some.Module", :fun, 2}} == Utils.parse_mfa(":'Some.Module'.fun/2")
end
test "invalid" do
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("Some..Module.fun/2")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("Some.Module.fun/-2")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa(".fun/2")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("fun/2")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("some_module.fun/2")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa(":some_module.fun/")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa(":some_module.fun")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa(":some_module.")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa(":some_module")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("some_module")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa(":")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("/")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("/2")
assert {:error, "cannot parse MFA"} == Utils.parse_mfa("")
end
end
describe "positions" do
test "dap_character_to_elixir empty" do
assert 0 == Utils.dap_character_to_elixir("", 0)
end
test "dap_character_to_elixir empty after end" do
assert 0 == Utils.dap_character_to_elixir("", 1)
end
test "dap_character_to_elixir first char" do
assert 0 == Utils.dap_character_to_elixir("abcde", 0)
end
test "dap_character_to_elixir line" do
assert 1 == Utils.dap_character_to_elixir("abcde", 1)
end
test "dap_character_to_elixir before line start" do
assert 0 == Utils.dap_character_to_elixir("abcde", -1)
end
test "dap_character_to_elixir after line end" do
assert 5 == Utils.dap_character_to_elixir("abcde", 15)
end
test "dap_character_to_elixir utf8" do
assert 1 == Utils.dap_character_to_elixir("🏳️🌈abcde", 6)
end
test "dap_character_to_elixir index inside high surrogate pair" do
assert 6 == Utils.dap_character_to_elixir("Hello 🙌 World", 6)
assert 6 == Utils.dap_character_to_elixir("Hello 🙌 World", 7)
assert 7 == Utils.dap_character_to_elixir("Hello 🙌 World", 8)
end
test "dap_character_to_elixir invalid utf8" do
assert_raise ArgumentError, ~r/could not convert characters/, fn ->
Utils.dap_character_to_elixir(<<0x80>>, 1)
end
end
end
end