-
-
Notifications
You must be signed in to change notification settings - Fork 283
test(proxySet): add test for 'intersection' with Set-like object using 'forEach' fallback #1211
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -854,6 +854,24 @@ describe('proxySet', () => { | |||||
| expect(result).toEqual(proxySet([1, 9])) | ||||||
| }) | ||||||
|
|
||||||
| it('.intersection with Set-like object that has forEach but is not iterable', () => { | ||||||
| const odds = proxySet([1, 3, 5, 7, 9]) | ||||||
| const setLike = { | ||||||
| size: 3, | ||||||
| has(v: number) { | ||||||
| return [1, 4, 9].includes(v) | ||||||
| }, | ||||||
| keys() { | ||||||
| return [1, 4, 9].values() | ||||||
| }, | ||||||
| forEach(cb: (v: number) => void) { | ||||||
| ;[1, 4, 9].forEach(cb) | ||||||
|
||||||
| ;[1, 4, 9].forEach(cb) | |
| [1, 4, 9].forEach(cb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot doesn't know prettier. 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this instead of native
Set?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dai-shi Native
SetandproxySethaveSymbol.iterator, so they pass theisIterablecheck and skip thehasForEachpath (line 92, 96-99). A Set-like object withoutSymbol.iteratoris needed to cover theforEachfallback inasIterable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll defer the review to copilot and @overthemike .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the wait. I see what you're going for here. Is there a reason we're only testing for interesection?