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.keys and Object.entries #1471

Merged
merged 11 commits into from
Aug 22, 2021
Merged

Implement Object.keys and Object.entries #1471

merged 11 commits into from
Aug 22, 2021

Conversation

skyne98
Copy link
Contributor

@skyne98 skyne98 commented Aug 15, 2021

This Pull Request adds the Object.keys(...) function.

It's my first contribution, sorry if something is missing, incorrect or dirty, I tried to implement it to-spec.

@HalidOdat HalidOdat added builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request labels Aug 17, 2021
@HalidOdat HalidOdat added this to the v0.13.0 milestone Aug 17, 2021
@skyne98
Copy link
Contributor Author

skyne98 commented Aug 19, 2021

@jedel1043, done-zo

@skyne98
Copy link
Contributor Author

skyne98 commented Aug 19, 2021

Also, I will probably create a new pull request after this one to add Object.entries(...) because under the hood it's nearly the same as Object.keys(...)!

@jedel1043
Copy link
Member

Also, I will probably create a new pull request after this one to add Object.entries(...) because under the hood it's nearly the same as Object.keys(...)!

If Object.entries is simple enough, I don't see a problem with adding it in this PR. There have been several PRs with contributions implementing multiple simple methods.

boa/src/property/mod.rs Outdated Show resolved Hide resolved
boa/src/object/internal_methods.rs Outdated Show resolved Hide resolved
boa/src/object/internal_methods.rs Outdated Show resolved Hide resolved
boa/src/builtins/object/mod.rs Outdated Show resolved Hide resolved
boa/src/builtins/object/mod.rs Outdated Show resolved Hide resolved
@jedel1043
Copy link
Member

I just realized there are several PropertyNameKind in the codebase. Specifically in:

https://github.com/boa-dev/boa/blob/62ad20cfde0a545f35d8af07c36cd5d32a7479f4/boa/src/builtins/map/map_iterator.rs
https://github.com/boa-dev/boa/blob/62ad20cfde0a545f35d8af07c36cd5d32a7479f4/boa/src/builtins/array/array_iterator.rs
https://github.com/boa-dev/boa/blob/62ad20cfde0a545f35d8af07c36cd5d32a7479f4/boa/src/builtins/set/set_iterator.rs

Commenting this as a reminder to refactor these when your PR merges. If you're interested, you can fix this, but it's not necessary to approve this PR.

boa/src/builtins/object/mod.rs Outdated Show resolved Hide resolved
boa/src/builtins/object/mod.rs Outdated Show resolved Hide resolved
boa/src/property/mod.rs Outdated Show resolved Hide resolved
@skyne98
Copy link
Contributor Author

skyne98 commented Aug 21, 2021

@jedel1043, @HalidOdat, committed the changes, guys!

@skyne98
Copy link
Contributor Author

skyne98 commented Aug 21, 2021

Also added the Object.entries(...) as you suggested. Didn't refactor the duplicated enums for now, I think you would find a much better place for it with your codebase knowledge!

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.

Just small nitpicks before approving. Everything else looks good!

boa/src/builtins/object/mod.rs Outdated Show resolved Hide resolved
boa/src/builtins/object/mod.rs Outdated Show resolved Hide resolved
boa/src/object/internal_methods.rs Outdated Show resolved Hide resolved
@skyne98
Copy link
Contributor Author

skyne98 commented Aug 21, 2021

Thanks for suggestions, should be committed now!

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.

Looks good!

@HalidOdat
Copy link
Member

Test result master count PR count difference
Total 78,897 78,897 0
Passed 30,922 31,062 +140
Ignored 15,612 15,612 0
Failed 32,363 32,223 -140
Panics 2 2 0
Conformance 39.19% 39.37% +0.18%
Fixed tests:
test/built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-26.js [strict mode] (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-26.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-1-3.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-1-3.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-0-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-0-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-5.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-5.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-11.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-11.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-2.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-2.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-0-2.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-0-2.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-4.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-4.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-16.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-16.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-7.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-7.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-12.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-12.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-5.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-5.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-6.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-6.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-8.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-8.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-1-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-1-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-3.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-3.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-2.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-2.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-2.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-2.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-6.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-6.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-15.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-15.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-3-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-2.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-2.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-3.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-3.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-b-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-b-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-2.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-2.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-3.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-a-3.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-7.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-7.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-4.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-4.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-1-2.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-1-2.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-5.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-6-5.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-1.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-1.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-7.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-7.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-3.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-2-3.js (previously Failed)
test/built-ins/Object/keys/name.js [strict mode] (previously Failed)
test/built-ins/Object/keys/name.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-10.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-10.js (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-9.js [strict mode] (previously Failed)
test/built-ins/Object/keys/15.2.3.14-5-9.js (previously Failed)
test/built-ins/Object/entries/function-length.js [strict mode] (previously Failed)
test/built-ins/Object/entries/function-length.js (previously Failed)
test/built-ins/Object/entries/primitive-numbers.js [strict mode] (previously Failed)
test/built-ins/Object/entries/primitive-numbers.js (previously Failed)
test/built-ins/Object/entries/tamper-with-object-keys.js [strict mode] (previously Failed)
test/built-ins/Object/entries/tamper-with-object-keys.js (previously Failed)
test/built-ins/Object/entries/function-name.js [strict mode] (previously Failed)
test/built-ins/Object/entries/function-name.js (previously Failed)
test/built-ins/Object/entries/primitive-booleans.js [strict mode] (previously Failed)
test/built-ins/Object/entries/primitive-booleans.js (previously Failed)
test/built-ins/Object/entries/symbols-omitted.js [strict mode] (previously Failed)
test/built-ins/Object/entries/symbols-omitted.js (previously Failed)
test/built-ins/Object/entries/inherited-properties-omitted.js [strict mode] (previously Failed)
test/built-ins/Object/entries/inherited-properties-omitted.js (previously Failed)
test/built-ins/Object/entries/primitive-symbols.js [strict mode] (previously Failed)
test/built-ins/Object/entries/primitive-symbols.js (previously Failed)
test/built-ins/Object/entries/function-property-descriptor.js [strict mode] (previously Failed)
test/built-ins/Object/entries/function-property-descriptor.js (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/primitive-numbers.js [strict mode] (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/primitive-numbers.js (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/tamper-with-object-keys.js [strict mode] (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/tamper-with-object-keys.js (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/primitive-booleans.js [strict mode] (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/primitive-booleans.js (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/inherited-properties-omitted.js [strict mode] (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/inherited-properties-omitted.js (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/primitive-symbols.js [strict mode] (previously Failed)
test/built-ins/Object/getOwnPropertyDescriptors/primitive-symbols.js (previously Failed)
test/built-ins/Object/defineProperty/15.2.3.6-4-610.js [strict mode] (previously Failed)
test/built-ins/Object/defineProperty/15.2.3.6-4-610.js (previously Failed)
test/language/expressions/array/spread-obj-skip-non-enumerable.js [strict mode] (previously Failed)
test/language/expressions/array/spread-obj-skip-non-enumerable.js (previously Failed)
test/language/expressions/array/spread-mult-obj-undefined.js [strict mode] (previously Failed)
test/language/expressions/array/spread-mult-obj-undefined.js (previously Failed)
test/language/expressions/array/spread-mult-obj-null.js [strict mode] (previously Failed)
test/language/expressions/array/spread-mult-obj-null.js (previously Failed)
test/language/expressions/array/spread-obj-null.js [strict mode] (previously Failed)
test/language/expressions/array/spread-obj-null.js (previously Failed)
test/language/expressions/array/spread-obj-undefined.js [strict mode] (previously Failed)
test/language/expressions/array/spread-obj-undefined.js (previously Failed)
test/language/expressions/call/spread-obj-skip-non-enumerable.js [strict mode] (previously Failed)
test/language/expressions/call/spread-obj-skip-non-enumerable.js (previously Failed)
test/language/expressions/call/spread-mult-obj-undefined.js [strict mode] (previously Failed)
test/language/expressions/call/spread-mult-obj-undefined.js (previously Failed)
test/language/expressions/call/spread-mult-obj-null.js [strict mode] (previously Failed)
test/language/expressions/call/spread-mult-obj-null.js (previously Failed)
test/language/expressions/call/spread-obj-null.js [strict mode] (previously Failed)
test/language/expressions/call/spread-obj-null.js (previously Failed)
test/language/expressions/call/spread-obj-undefined.js [strict mode] (previously Failed)
test/language/expressions/call/spread-obj-undefined.js (previously Failed)
test/language/expressions/new/spread-obj-skip-non-enumerable.js [strict mode] (previously Failed)
test/language/expressions/new/spread-obj-skip-non-enumerable.js (previously Failed)
test/language/expressions/new/spread-mult-obj-undefined.js [strict mode] (previously Failed)
test/language/expressions/new/spread-mult-obj-undefined.js (previously Failed)
test/language/expressions/new/spread-mult-obj-null.js [strict mode] (previously Failed)
test/language/expressions/new/spread-mult-obj-null.js (previously Failed)
test/language/expressions/new/spread-obj-null.js [strict mode] (previously Failed)
test/language/expressions/new/spread-obj-null.js (previously Failed)
test/language/expressions/new/spread-obj-undefined.js [strict mode] (previously Failed)
test/language/expressions/new/spread-obj-undefined.js (previously Failed)
test/harness/deepEqual-primitives-bigint.js [strict mode] (previously Failed)
test/harness/deepEqual-primitives-bigint.js (previously Failed)

@HalidOdat HalidOdat changed the title Implement Object.keys Implement Object.keys and Object.entries Aug 22, 2021
@HalidOdat HalidOdat merged commit 5ee865f into boa-dev:master Aug 22, 2021
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants