Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertEquals throws when comparing unique symbols without showing the difference #3370

Open
jespertheend opened this issue May 7, 2023 · 2 comments
Labels
bug Something isn't working needs triage

Comments

@jespertheend
Copy link
Contributor

Describe the bug

When two objects contain two unique symbols, assertEquals throws without any meaningful explanation.

Steps to Reproduce

import {assertEquals} from "https://deno.land/[email protected]/testing/asserts.ts";
assertEquals(Symbol(), Symbol());

results in the following error:

[Diff] Actual / Expected

Symbol()

Expected behavior

Whether the function should throw is up for debate I think. But the current error message is rather unclear.
This is just a simple example comparing two symbols, but the way I found out about this was because I was comparing two large structures where only a single symbol property was different.

Environment

  • OS: 22.10
  • deno version: 1.32.1
  • std version: 0.186.0
@jespertheend jespertheend added bug Something isn't working needs triage labels May 7, 2023
@denizdogan
Copy link
Contributor

Just out of curiosity, what should the diff show in your example?

@jespertheend
Copy link
Contributor Author

In the example above, I think just making the Symbol() red should be enough.
In case of more complex cases ideally it would highlight the unique symbols that are different while keeping the rest gray as it currently is.

Not sure how feasible this is though, maybe just including the name of the property that has a mismatch in the error message would already be a lot more helpful.
For instance

const obj = {
	path: {
		to: {
			object: {
				[Symbol()]: "value"
			}
		}
	}
}

could show the message

Values at "path.to.object" are not reference-equal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants