Skip to content

Commit

Permalink
correct existing tests to include Set and Dict fromList merges
Browse files Browse the repository at this point in the history
  • Loading branch information
lue-bird authored and jfmengels committed Dec 27, 2024
1 parent 27e01b0 commit 25cc054
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
22 changes: 22 additions & 0 deletions tests/Simplify/DictTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,17 @@ a = Dict.size (Dict.fromList [(1,1), (2,1), (3,1), (3,2), (0x3,2)])
|> Review.Test.whenFixed """module A exposing (..)
import Dict
a = 3
"""
, Review.Test.error
{ message = "Dict.fromList on entries with a duplicate key will only keep the last entry"
, details = [ "Maybe one of the keys was supposed to be a different value? If not, you can remove earlier entries with duplicate keys." ]
, under = "3"
}
|> Review.Test.atExactly
{ start = { row = 3, column = 46 }, end = { row = 3, column = 47 } }
|> Review.Test.whenFixed """module A exposing (..)
import Dict
a = Dict.size (Dict.fromList [(1,1), (2,1), (3,2), (0x3,2)])
"""
]
, test "should replace Dict.size (Dict.fromList [(1.3,()), (-1.3,()), (2.1,()), (2.1,())]) by 3" <|
Expand All @@ -595,6 +606,17 @@ a = Dict.size (Dict.fromList [(1.3,()), (-1.3,()), (2.1,()), (2.1,())])
|> Review.Test.whenFixed """module A exposing (..)
import Dict
a = 3
"""
, Review.Test.error
{ message = "Dict.fromList on entries with a duplicate key will only keep the last entry"
, details = [ "Maybe one of the keys was supposed to be a different value? If not, you can remove earlier entries with duplicate keys." ]
, under = "2.1"
}
|> Review.Test.atExactly
{ start = { row = 3, column = 53 }, end = { row = 3, column = 56 } }
|> Review.Test.whenFixed """module A exposing (..)
import Dict
a = Dict.size (Dict.fromList [(1.3,()), (-1.3,()), (2.1,())])
"""
]
]
Expand Down
68 changes: 67 additions & 1 deletion tests/Simplify/SetTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,20 @@ a = Set.size (Set.fromList [1, 2, 3, 3, 0x3])
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = 3
"""
, 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 = "3"
}
|> Review.Test.atExactly
{ start = { row = 3, column = 35 }, end = { row = 3, column = 36 } }
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.size (Set.fromList [1, 2, 3, 0x3])
"""
]
, test "should replace Set.size (Set.fromList [2, -2, -(-2)]) by 2" <|
, test "should replace Set.size (Set.fromList [2, -2, -2]) by 2" <|
\() ->
"""module A exposing (..)
import Set
Expand All @@ -630,6 +641,17 @@ a = Set.size (Set.fromList [2, -2, -2])
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = 2
"""
, 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 = "-2"
}
|> Review.Test.atExactly
{ start = { row = 3, column = 32 }, end = { row = 3, column = 34 } }
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.size (Set.fromList [2, -2])
"""
]
, test "should replace Set.size (Set.fromList [1.3, -1.3, 2.1, 2.1]) by 3" <|
Expand All @@ -648,6 +670,17 @@ a = Set.size (Set.fromList [1.3, -1.3, 2.1, 2.1])
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = 3
"""
, 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 = "2.1"
}
|> Review.Test.atExactly
{ start = { row = 3, column = 40 }, end = { row = 3, column = 43 } }
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.size (Set.fromList [1.3, -1.3, 2.1])
"""
]
, test "should replace Set.size (Set.fromList [\"foo\", \"bar\", \"foo\"]) by 2" <|
Expand All @@ -666,6 +699,17 @@ a = Set.size (Set.fromList ["foo", "bar", "foo"])
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = 2
"""
, 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 = "\"foo\""
}
|> Review.Test.atExactly
{ start = { row = 3, column = 29 }, end = { row = 3, column = 34 } }
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.size (Set.fromList ["bar", "foo"])
"""
]
, test "should replace Set.size (Set.fromList ['a', 'b', ('a')]) by 2" <|
Expand All @@ -684,6 +728,17 @@ a = Set.size (Set.fromList ['a', 'b', ('a')])
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = 2
"""
, 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 = 29 }, end = { row = 3, column = 32 } }
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.size (Set.fromList ['b', ('a')])
"""
]
, test "should replace Set.size (Set.fromList [([1, 2], [3, 4]), ([1, 2], [3, 4]), ([], [1])]) by 2" <|
Expand All @@ -702,6 +757,17 @@ a = Set.size (Set.fromList [([1, 2], [3, 4]), ([1, 2], [3, 4]), ([], [1])])
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = 2
"""
, 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 = "([1, 2], [3, 4])"
}
|> Review.Test.atExactly
{ start = { row = 3, column = 29 }, end = { row = 3, column = 45 } }
|> Review.Test.whenFixed """module A exposing (..)
import Set
a = Set.size (Set.fromList [([1, 2], [3, 4]), ([], [1])])
"""
]
, test "should replace Set.empty |> Set.size by 0" <|
Expand Down

0 comments on commit 25cc054

Please sign in to comment.