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

@std/assert/equals considers Object.create(null) and {} to be equal #6334

Open
lilnasy opened this issue Jan 6, 2025 · 2 comments
Open

@std/assert/equals considers Object.create(null) and {} to be equal #6334

lilnasy opened this issue Jan 6, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@lilnasy
Copy link

lilnasy commented Jan 6, 2025

Describe the bug

  • Since fix(assert): check property equality up the prototype chain (#6151) #6153, assertEquals checks object prototypes. However, it makes certain exceptions to keep existing tests within the repo from failing.
  • Other assertion libraries have more correct checks: "node:assert/strict", "ava", and "uvu" all make a distinction between null-prototype object and plain objects. "node:assert" and "chai" don't.

Steps to Reproduce
The following assertion passes:

import { assertEquals } from "@std/assert"
assertEquals(Object.create(Object.prototype), Object.create(null))

Expected behavior
The assertion fails.

Environment
Not applicable.

@lilnasy lilnasy added bug Something isn't working needs triage labels Jan 6, 2025
@kt3k kt3k added feedback welcome We want community's feedback on this issue or PR and removed bug Something isn't working feedback welcome We want community's feedback on this issue or PR labels Jan 6, 2025
@kt3k
Copy link
Member

kt3k commented Jan 6, 2025

I don't get what this issue is about. The given example seems already failing.

@lilnasy
Copy link
Author

lilnasy commented Jan 6, 2025

You're right, my steps to reproduce were incorrect.

- assertEquals(Object.create(Object), Object.create(null))
+ assertEquals(Object.create(Object.prototype), Object.create(null))

@kt3k kt3k added bug Something isn't working and removed needs triage labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants