-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update erlex, remove unused `require Logger`, add test for `prefix_stream/2` * fix credo errors
- Loading branch information
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
defmodule Lexical.Ast.TokensTest do | ||
alias Lexical.Ast.Tokens | ||
|
||
import Lexical.Test.CodeSigil | ||
import Lexical.Test.CursorSupport | ||
|
||
use ExUnit.Case, async: true | ||
|
||
describe "prefix_stream/2" do | ||
test "works as intended" do | ||
text = ~q[ | ||
defmodule Foo do | ||
def bar do | ||
| | ||
end | ||
end | ||
] | ||
|
||
{position, document} = pop_cursor(text, as: :document) | ||
|
||
tokens = Tokens.prefix_stream(document, position) | ||
|
||
assert Enum.to_list(tokens) == [ | ||
{:eol, ~c"\n", []}, | ||
{:operator, :do, {2, 11}}, | ||
{:do_identifier, ~c"bar", {2, 7}}, | ||
{:identifier, ~c"def", {2, 3}}, | ||
{:eol, ~c"\n", []}, | ||
{:operator, :do, {1, 15}}, | ||
{:alias, ~c"Foo", {1, 11}}, | ||
{:identifier, ~c"defmodule", {1, 1}} | ||
] | ||
end | ||
|
||
test "returns nothing when cursor is at start" do | ||
text = ~q[ | ||
|defmodule Foo do | ||
def bar do | ||
:bar | ||
end | ||
end | ||
] | ||
|
||
{position, document} = pop_cursor(text, as: :document) | ||
|
||
tokens = Tokens.prefix_stream(document, position) | ||
|
||
assert Enum.to_list(tokens) == [] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters