Skip to content

Commit

Permalink
fix flaky test relying on application env
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Nov 7, 2024
1 parent 8c3c36a commit 22ea52f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
24 changes: 24 additions & 0 deletions test/makeup/lexers/elixir_lexer/elixir_lexer_sigil_lexer_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
defmodule ElixirLexerSigilLexerTest do
use ExUnit.Case, async: false
import Makeup.Lexers.ElixirLexer.Testing, only: [lex: 1]

describe "custom lexers for sigils" do
test "can register a custom lexer" do
defmodule MyCustomLexer do
def lex(input) do
[{:keyword, %{}, input}]
end
end

Makeup.Lexers.ElixirLexer.register_sigil_lexer("H", MyCustomLexer)

assert lex("~H|Hello, world!|") == [
{:string_sigil, %{}, "~H|"},
{:keyword, %{}, "Hello, world!"},
{:string_sigil, %{}, "|"}
]
after
Application.put_env(:makeup_elixir, :sigil_lexers, %{})
end
end
end
18 changes: 0 additions & 18 deletions test/makeup/lexers/elixir_lexer/elixir_lexer_tokenizer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -695,22 +695,4 @@ defmodule ElixirLexerTokenizerTestSnippet do
{:punctuation, %{group_id: "group-1"}, "}"}
]
end

describe "custom lexers for sigils" do
test "can register a custom lexer" do
defmodule MyCustomLexer do
def lex(input) do
[{:keyword, %{}, input}]
end
end

Makeup.Lexers.ElixirLexer.register_sigil_lexer("H", MyCustomLexer)

assert lex("~H|Hello, world!|") == [
{:string_sigil, %{}, "~H|"},
{:keyword, %{}, "Hello, world!"},
{:string_sigil, %{}, "|"}
]
end
end
end

0 comments on commit 22ea52f

Please sign in to comment.