Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceful-james committed May 25, 2024
1 parent 953ce04 commit ccd5e70
Showing 1 changed file with 72 additions and 42 deletions.
114 changes: 72 additions & 42 deletions test/credo/code/token_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,42 @@ defmodule Credo.Code.TokenTest do
tokens = Credo.Code.to_tokens(source)

expected =
if Version.match?(System.version(), ">= 1.14.0-dev") do
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
@kw_identifier_token,
{:bin_string, {1, 28, nil},
[
{{1, 29, nil}, {1, 39, nil}, [{:identifier, {1, 31, ~c"filename"}, :filename}]},
" world"
]},
{:"}", {1, 47, nil}}
]
else
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
@kw_identifier_token,
{:bin_string, {1, 28, nil},
[{{1, 29, nil}, {1, 39, nil}, [{:identifier, {1, 31, nil}, :filename}]}, " world"]},
{:"}", {1, 47, nil}}
]
cond do
Version.match?(System.version(), ">= 1.17.0-rc.0") ->
[
{:%{}, {1, 1, nil}},
{:"{", {1, 1, nil}},
@kw_identifier_token,
{:bin_string, {1, 28, nil},
[
{{1, 29, nil}, {1, 39, nil}, [{:identifier, {1, 31, ~c"filename"}, :filename}]},
" world"
]},
{:"}", {1, 47, nil}}
]

Version.match?(System.version(), ">= 1.14.0-dev") ->
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
@kw_identifier_token,
{:bin_string, {1, 28, nil},
[
{{1, 29, nil}, {1, 39, nil}, [{:identifier, {1, 31, ~c"filename"}, :filename}]},
" world"
]},
{:"}", {1, 47, nil}}
]

true ->
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
@kw_identifier_token,
{:bin_string, {1, 28, nil},
[{{1, 29, nil}, {1, 39, nil}, [{:identifier, {1, 31, nil}, :filename}]}, " world"]},
{:"}", {1, 47, nil}}
]
end

assert expected == tokens
Expand All @@ -271,27 +286,42 @@ defmodule Credo.Code.TokenTest do
tokens = Credo.Code.to_tokens(source)

expected =
if Version.match?(System.version(), ">= 1.14.0-dev") do
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
{:kw_identifier, {1, 3, ~c"some_atom_with_quotes"}, :some_atom_with_quotes},
{:bin_string, {1, 26, nil},
[
{{1, 27, nil}, {1, 37, nil}, [{:identifier, {1, 29, ~c"filename"}, :filename}]},
" world"
]},
{:"}", {1, 45, nil}}
]
else
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
{:kw_identifier, {1, 3, nil}, :some_atom_with_quotes},
{:bin_string, {1, 26, nil},
[{{1, 27, nil}, {1, 37, nil}, [{:identifier, {1, 29, nil}, :filename}]}, " world"]},
{:"}", {1, 45, nil}}
]
cond do
Version.match?(System.version(), ">= 1.17.0-rc.0") ->
[
{:%{}, {1, 1, nil}},
{:"{", {1, 1, nil}},
{:kw_identifier, {1, 3, ~c"some_atom_with_quotes"}, :some_atom_with_quotes},
{:bin_string, {1, 26, nil},
[
{{1, 27, nil}, {1, 37, nil}, [{:identifier, {1, 29, ~c"filename"}, :filename}]},
" world"
]},
{:"}", {1, 45, nil}}
]

Version.match?(System.version(), ">= 1.14.0-dev") ->
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
{:kw_identifier, {1, 3, ~c"some_atom_with_quotes"}, :some_atom_with_quotes},
{:bin_string, {1, 26, nil},
[
{{1, 27, nil}, {1, 37, nil}, [{:identifier, {1, 29, ~c"filename"}, :filename}]},
" world"
]},
{:"}", {1, 45, nil}}
]

true ->
[
{:%{}, {1, 1, nil}},
{:"{", {1, 2, nil}},
{:kw_identifier, {1, 3, nil}, :some_atom_with_quotes},
{:bin_string, {1, 26, nil},
[{{1, 27, nil}, {1, 37, nil}, [{:identifier, {1, 29, nil}, :filename}]}, " world"]},
{:"}", {1, 45, nil}}
]
end

assert expected == tokens
Expand Down

0 comments on commit ccd5e70

Please sign in to comment.