mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
expand Set test cases
This commit is contained in:
parent
cad7d8b4e9
commit
4befccc6b4
2 changed files with 34 additions and 28 deletions
|
@ -801,33 +801,12 @@ expect
|
|||
&& (get dict "g" == Ok 6)
|
||||
&& (get dict "h" == Ok 7)
|
||||
|
||||
# These are equivalent to the Set tests that are panicking for some reason.
|
||||
expect
|
||||
actual =
|
||||
empty
|
||||
|> insert "foo" {}
|
||||
|> insert "bar" {}
|
||||
|> insert "foo" {}
|
||||
|> insert "baz" {}
|
||||
|
||||
expected =
|
||||
empty
|
||||
|> insert "foo" {}
|
||||
|> insert "bar" {}
|
||||
|> insert "baz" {}
|
||||
|
||||
toList expected == toList actual
|
||||
|
||||
expect
|
||||
actual =
|
||||
empty
|
||||
|> insert "foo" {}
|
||||
|> insert "bar" {}
|
||||
|> insert "foo" {}
|
||||
|> insert "baz" {}
|
||||
|> len
|
||||
|
||||
actual == 3
|
||||
Dict.empty
|
||||
|> Dict.insert "Some" "Value"
|
||||
|> Dict.remove "Some"
|
||||
|> Dict.len
|
||||
|> Bool.isEq 0
|
||||
|
||||
# We have decided not to expose the standard roc hashing algorithm.
|
||||
# This is to avoid external dependence and the need for versioning.
|
||||
|
|
|
@ -105,7 +105,7 @@ fromList : List k -> Set k | k has Hash & Eq
|
|||
fromList = \list ->
|
||||
initial = @Set (Dict.withCapacity (List.len list))
|
||||
|
||||
List.walk list initial \set, key -> Set.insert set key
|
||||
List.walk list initial insert
|
||||
|
||||
union : Set k, Set k -> Set k | k has Hash & Eq
|
||||
union = \@Set dict1, @Set dict2 ->
|
||||
|
@ -175,4 +175,31 @@ expect
|
|||
|> insert 3
|
||||
|> insert 4
|
||||
|
||||
union first second == expected
|
||||
union first second == expected
|
||||
|
||||
expect
|
||||
base =
|
||||
single "Remove Me"
|
||||
|> insert "Keep Me"
|
||||
|> insert "And Me"
|
||||
|
||||
expected =
|
||||
single "Keep Me"
|
||||
|> insert "And Me"
|
||||
|
||||
remove base "Remove Me" == expected
|
||||
|
||||
expect
|
||||
x =
|
||||
single 0
|
||||
|> insert 1
|
||||
|> insert 2
|
||||
|> insert 3
|
||||
|> insert 4
|
||||
|> insert 5
|
||||
|> insert 6
|
||||
|> insert 7
|
||||
|> insert 8
|
||||
|> insert 9
|
||||
|
||||
x == fromList (toList x)
|
Loading…
Add table
Add a link
Reference in a new issue