elm-explorations / elm-explorations/test

Add Expect.equalArrays

Open
#237 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
244
Forks
40
Avg merge
1d 23h
Merged PRs (30d)
2

Description

When working with `Array`s, I often find myself needing to use write expectations for them in tests. Unfortunately, while [`Expect.equalLists`](https://package.elm-lang.org/packages/elm-explorations/test/latest/Expect#equalLists) exists (and the same for `Set`/`Dict`), `Expect.equalArrays` doesn't. Therefore I often end up needing to write something like this:

```elm
some operation
|> Array.toList
|> Expect.equalLists [ ... ]
```

Adding a `expectArrays : Array a -> Array a -> Expectation` function would forego the need for the manual and maybe confusing conversion.

What I'm unsure of, is whether there should also be a function that—for convenience's sake—takes a `List a` for the expected collection.

```elm
expect??? : List a -> Array a -> Expectation

--

some operation
|> Expect.equal??? [ 1, 2, 3 ]
-- instead of
some operation
|> Expect.equal??? (Array.fromList [ 1, 2, 3 ])
-- or
some operation
|> Array.toList
|> Expect.equalLists [ 1, 2, 3 ]
```

This could be beneficial for `equalSets` and `equalDicts` as well.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.