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

Implement Object.fromEntries #1660

Merged
merged 2 commits into from
Oct 12, 2021
Merged

Conversation

kevinputera
Copy link
Contributor

This Pull Request fixes/closes #1580. It implements the final method described in that issue, i.e. Object.fromEntries.

Changes:

  • Implement Object.fromEntries.
  • Tests for Object.fromEntries.

@kevinputera
Copy link
Contributor Author

Test262 conformance changes:

Test result main count PR count difference
Total 86,438 86,438 0
Passed 37,716 37,762 +46
Ignored 19,022 19,022 0
Failed 29,700 29,654 -46
Panics 0 0 0
Conformance 43.63% 43.69% +0.05%
Fixed tests (46):
test/built-ins/Object/fromEntries/requires-argument.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/requires-argument.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-done-accessor.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-done-accessor.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-next-returning-non-object.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-next-returning-non-object.js (previously Failed)
test/built-ins/Object/fromEntries/empty-iterable.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/empty-iterable.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-tostring.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-tostring.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-uncallable-next.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-uncallable-next.js (previously Failed)
test/built-ins/Object/fromEntries/prototype.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/prototype.js (previously Failed)
test/built-ins/Object/fromEntries/name.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/name.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js (previously Failed)
test/built-ins/Object/fromEntries/length.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/length.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js (previously Failed)
test/built-ins/Object/fromEntries/key-order.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/key-order.js (previously Failed)
test/built-ins/Object/fromEntries/uses-define-semantics.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/uses-define-semantics.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-value-accessor.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-value-accessor.js (previously Failed)
test/built-ins/Object/fromEntries/string-entry-primitive-throws.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/string-entry-primitive-throws.js (previously Failed)
test/built-ins/Object/fromEntries/simple-properties.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/simple-properties.js (previously Failed)
test/built-ins/Object/fromEntries/supports-symbols.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/supports-symbols.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-accessor.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-accessor.js (previously Failed)
test/built-ins/Object/fromEntries/string-entry-string-object-succeeds.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/string-entry-string-object-succeeds.js (previously Failed)
test/built-ins/Object/fromEntries/string-entry-object-succeeds.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/string-entry-object-succeeds.js (previously Failed)
test/built-ins/Object/fromEntries/uses-keys-not-iterator.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/uses-keys-not-iterator.js (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-next.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-next.js (previously Failed)
test/built-ins/Object/fromEntries/to-property-key.js [strict mode] (previously Failed)
test/built-ins/Object/fromEntries/to-property-key.js (previously Failed)

@kevinputera
Copy link
Contributor Author

kevinputera commented Oct 11, 2021

One of the conformance tests, i.e. built-ins/Object/fromEntries/evaluation-order.js, is failing for a very surprising reason (message = Expected SameValue(«undefined», «first value») to be true).

I created a file (here's the gist) containing the relevant files concatenated to replicate this behaviour. Unfortunately, I still can't figure out what went wrong for now, but I found out how to trigger/un-trigger the error condition.

If we comment out this section of the file, it will run successfully. Otherwise, it will fail because Object.fromEntries returns a boolean value for some reason 🤔

Does anyone knows what might cause this?

EDIT: I think this is caused by the usage of var result in multiple scopes. Could it be that our implementation of var is not spec compliant yet?

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I would say we merge this and open an issue for the one missing test. I have not looked in detail, but I agree that it is probably something separate from this implementation.

@kevinputera
Copy link
Contributor Author

Looks good to me.

I would say we merge this and open an issue for the one missing test. I have not looked in detail, but I agree that it is probably something separate from this implementation.

Sure! I will create an issue once this is merged.

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Let's merge this :)

@jedel1043 jedel1043 merged commit 4f9764c into boa-dev:main Oct 12, 2021
@kevinputera kevinputera deleted the object-from-entries branch October 12, 2021 14:15
@jedel1043 jedel1043 added builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com labels Oct 14, 2021
@Razican Razican added this to the v0.14.0 milestone Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement missing static Object methods
4 participants