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

Tests for Symbols as WeakMap keys proposal #3678

Merged
merged 8 commits into from
Oct 12, 2022

Conversation

ptomato
Copy link
Contributor

@ptomato ptomato commented Sep 29, 2022

Tests for the Symbols as WeakMap keys proposal which reached Stage 3 in June 2022.

Note that because I updated the frontmatter to reflect the changes in the proposal's spec text, rename detection is not working on some of these files.

Closes: #2850

@ptomato ptomato requested a review from a team as a code owner September 29, 2022 00:10
@Ms2ger Ms2ger self-assigned this Oct 10, 2022
@ptomato ptomato added the has consensus This has committee consensus label Oct 10, 2022
rwaldron and others added 8 commits October 12, 2022 09:54
This test is duplicated by WeakSet/prototype/add/value-not-object-throw.js

Originally taken from Rick's draft commit for symbols-as-weakmap-keys
tests.
…map-keys

Originally taken from Rick's draft commit for symbols-as-weakmap-keys
tests.
WeakMap, WeakSet, WeakRef, and FinalizationRegistry all had tests
verifying what would happen if they were called with a value that wasn't
allowed as a weak value: before this proposal, that was a non-Object.
Now, allowed weak values are Objects, well-known Symbols, and unregistered
Symbols. That leaves registered Symbols that are still not allowed as weak
values.

This commit updates those tests to use a registered Symbol instead of an
unregistered Symbol; they should still pass, regardless of whether the
implementation has implemented symbols-as-weakmap-keys yet.

The tests are renamed as appropriate.

Also updates the frontmatter to the most current spec text, including the
CanBeHeldWeakly abstract operation.

See: tc39#2850
There are many existing tests for WeakMap, WeakSet, WeakRef, and
FinalizationRegistry using Objects as weak values. For symbols-as-weakmap-
keys, we'll want to write tests that parallel these for Symbol keys.

Change the descriptions and filenames of these tests to describe their new
scope of only Object weak values.

Update the front matter of these tests while we're at it, to reflect the
changes to the spec text that the symbols-as-weakmap-keys brings in. (In
some cases, remove irrelevant bits of the front matter.)

See: tc39#2850
This adds tests to WeakMap, WeakSet, WeakRef, and FinalizationRegistry for
Symbols as weakly-held values. Regular symbols and well-known symbols are
both tested. These tests correspond to existing tests for Objects as
weakly-held values, but are put in separate files so that they can be
filtered out with the "symbols-as-weakmap-keys" feature flag.

Registered symbols are not allowed; this is already tested in the "cannot-
be-held-weakly" tests.

See: tc39#2850
It's possible for an async test to throw a Symbol (harness/async-gc.js
does this.) The Symbol ends up getting passed to $DONE in a
.then($DONE, $DONE) call. Previously, $DONE would then throw an exception
due to not being able to convert the Symbol to a string.
This looks like a bug: resolveAsyncGC() is supposed to succeed if the
thrown value is asyncGC.notCollected, but instead it would call $DONE()
twice. An added "return" prevents that.
@Ms2ger Ms2ger force-pushed the symbols-as-weakmap-keys branch from 778db61 to 5ec189d Compare October 12, 2022 07:55
@Ms2ger Ms2ger enabled auto-merge (rebase) October 12, 2022 07:55
@Ms2ger Ms2ger merged commit ee7c379 into tc39:main Oct 12, 2022
@ptomato ptomato deleted the symbols-as-weakmap-keys branch October 12, 2022 14:35
webkit-commit-queue pushed a commit to sosukesuzuki/WebKit that referenced this pull request May 6, 2024
…iles

https://bugs.webkit.org/show_bug.cgi?id=273746

Reviewed by Yusuke Suzuki.

We had been skipping several test262 test cases that were broken due to the implementation of the
Symbols as WeakMap keys proposal[1]. However, those tests have been fixed or removed in
tc39/test262#3678[2].

This patch removes those tests from the skipped files.

[1]: https://github.com/tc39/proposal-symbols-as-weakmap-keys
[2]: tc39/test262#3678

* JSTests/test262/config.yaml:

Canonical link: https://commits.webkit.org/278395@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has consensus This has committee consensus needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permit Symbol as WeakMap key and WeakSet entry
3 participants