Skip to content

etl: use == for Map comparison in tests#92

Closed
dreig wants to merge 1 commit intoexercism:mainfrom
dreig:patch-1
Closed

etl: use == for Map comparison in tests#92
dreig wants to merge 1 commit intoexercism:mainfrom
dreig:patch-1

Conversation

@dreig
Copy link

@dreig dreig commented May 17, 2023

Use == in tests as it compares the contents of the maps, instead of === which is more strict as requires the two objects to be structurally identical, and may fail depending on how the maps were constructed. https://share.unison-lang.org/@unison/p/code/latest/terms/public/base/latest/data/Map/%3D%3D

The following solution was failing on the second test:

etl.transform : Map Nat [Char] -> Map Char Nat
etl.transform lettersByScore = 
  use Char toLowercase
  fn mp score chars = List.foldLeft (acc ch -> Map.put (toLowercase ch) score acc) mp chars
  Map.foldLeftWithKey fn Map.empty lettersByScore

Use `==` in tests as it compares the contents of the maps, instead of `===` which is more strict as requires the two objects to be structurally identical, and may fail depending on how the maps were constructed.
https://share.unison-lang.org/@unison/p/code/latest/terms/public/base/latest/data/Map/%3D%3D
@github-actions
Copy link
Contributor

Hello. Thanks for opening a PR on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed.

That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use this link to copy this into a new topic there.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this May 17, 2023
@rlmark
Copy link
Contributor

rlmark commented May 24, 2023

Thank you @dreig! I'm reopening this and have requested that community contributions be accepted for this repo here.

@rlmark rlmark reopened this May 24, 2023
@psftw
Copy link

psftw commented Jan 17, 2026

I just ran in to this. I needed to add |> Map.toList |> Map.fromList to get tests passing on Exercism, similar to the original author. A rebased commit is here in case it is useful.

Thanks for putting this together, it's been a lot of fun so far! ❤️

@SimaDovakin
Copy link
Contributor

Thank you for reporting this. Here is my fix: #163. Instead of ensure expected == actual I use ensureEqualWith (==) expected actual. It works like ensureEqual but uses specific function for comparison (== in this case). After @rlmark 's review I will merge it

@SimaDovakin
Copy link
Contributor

FIxed in #163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants