Skip to content

Add Expect.equalArrays #237

@jfmengels

Description

@jfmengels

When working with Arrays, I often find myself needing to use write expectations for them in tests. Unfortunately, while Expect.equalLists exists (and the same for Set/Dict), Expect.equalArrays doesn't. Therefore I often end up needing to write something like this:

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions