Skip to content

Commit

Permalink
indentation test +
Browse files Browse the repository at this point in the history
  • Loading branch information
lue-bird committed Jul 20, 2023
1 parent 98f4ed3 commit d314d91
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion tests/EqualsCaseableTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,53 @@ a =
, "You can replace this check with a `case of` where you use the value you're matching for as a pattern."
, "This can aid structuring your code in a way where the compiler knows as much about the current branch as you. Read more in the readme: https://dark.elm.dmy.fr/packages/lue-bird/elm-review-equals-caseable/latest/"
]
, under = "=="
, under = "list == []"
}
|> Review.Test.whenFixed
"""module A exposing (..)
a =
case list of
[] ->
"empty"
_ ->
"filled"
"""
]
, test "should report if == [] and keep indentation" <|
\() ->
"""module A exposing (..)
a =
List.reverse
(if list == [] then
"empty"
else
"filled"
)
"""
|> Review.Test.run (forbid EqualsCaseable.Everywhere)
|> Review.Test.expectErrors
[ Review.Test.error
{ message = "equivalent `case of` exists"
, details =
[ "You are checking for equality against a value that could be a pattern in an equivalent `case of`!"
, "You can replace this check with a `case of` where you use the value you're matching for as a pattern."
, "This can aid structuring your code in a way where the compiler knows as much about the current branch as you. Read more in the readme: https://dark.elm.dmy.fr/packages/lue-bird/elm-review-equals-caseable/latest/"
]
, under = "list == []"
}
|> Review.Test.whenFixed
"""module A exposing (..)
a =
List.reverse
(case list of
[] ->
"empty"
_ ->
"filled"
)
"""
]
]

0 comments on commit d314d91

Please sign in to comment.