Skip to content

Commit

Permalink
Add test for Set.fromList that nothing extra gets removed
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Jan 6, 2025
1 parent 313b064 commit 8dc0fab
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Simplify/SetTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,25 @@ a = Set.fromList [ ( 1, "", [ 'a' ] ), ( 1, "", [ 'a' ] ) ]
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.fromList [ ( 1, "", [ 'a' ] ) ]
"""
]
, test "should replace Set.fromList [ 'a', thing, 'a' ] by Set.fromList [ thing, 'a' ]" <|
\() ->
"""module A exposing (..)
import Set
a = Set.fromList [ 'a', thing, 'a' ]
"""
|> Review.Test.run ruleWithDefaults
|> Review.Test.expectErrors
[ Review.Test.error
{ message = "Set.fromList on a list with a duplicate key will only keep one of them"
, details = [ "Maybe one of the keys was supposed to be a different value? If not, you can remove one of the duplicate keys." ]
, under = "'a'"
}
|> Review.Test.atExactly { start = { row = 3, column = 20 }, end = { row = 3, column = 23 } }
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.fromList [ thing, 'a' ]
"""
]
]
Expand Down

0 comments on commit 8dc0fab

Please sign in to comment.