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.hasOwn and improve Object.prototype.hasOwnProperty #1639

Merged
merged 6 commits into from
Oct 7, 2021

Conversation

kevinputera
Copy link
Contributor

@kevinputera kevinputera commented Oct 6, 2021

This Pull Request partially fixes/closes #1580. The last unimplemented method from #1580, i.e. Object.fromEntries, will be implemented in a separate PR.

In addition to implementing Object.hasOwn, I decided to also make some changes to improve the existing Object.prototype.hasOwnProperty implementation (in the same PR since it is nearly identical to Object.hasOwn).

It changes the following:

  • Added implementation for Object.hasOwn.
  • Added tests for Object.hasOwn.
  • Fix docs typo and add more docs for Object.prototype.hasOwnProperty.
  • More tests for Object.prototype.hasOwnProperty.
  • Small bug fix regarding Object.prototype.hasOwnProperty's 'length' property.

@@ -54,7 +54,7 @@ impl BuiltIn for Object {
.name(Self::NAME)
.length(Self::LENGTH)
.inherit(JsValue::null())
.method(Self::has_own_property, "hasOwnProperty", 0)
.method(Self::has_own_property, "hasOwnProperty", 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this change, test/built-ins/Object/prototype/hasOwnProperty conformance is now 100%.

Copy link
Contributor Author

@kevinputera kevinputera Oct 6, 2021

Choose a reason for hiding this comment

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

I suspect similar bugs are present elsewhere, e.g. propertyIsEnumerable below. I don't make the change here, though, since I think it's quite unrelated with the changes made in this PR.

boa/src/builtins/object/tests.rs Show resolved Hide resolved
@kevinputera
Copy link
Contributor Author

kevinputera commented Oct 6, 2021

Test262 conformance changes:

Test result main count PR count difference
Total 86,438 86,438 0
Passed 37,324 37,442 +118
Ignored 19,022 19,022 0
Failed 30,092 29,974 -118
Panics 0 0 0
Conformance 43.18% 43.32% +0.14%
Fixed tests (118):
test/built-ins/Object/hasOwn/hasown_own_setter_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_nonexistent.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_nonexistent.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwritable_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwritable_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/name.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/name.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_exists.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_exists.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwriteable_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwriteable_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/symbol_property_toPrimitive.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/symbol_property_toPrimitive.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/symbol_own_property.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/symbol_own_property.js (previously Failed)
test/built-ins/Object/hasOwn/symbol_property_valueOf.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/symbol_property_valueOf.js (previously Failed)
test/built-ins/Object/hasOwn/symbol_property_toString.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/symbol_property_toString.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/prototype.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/prototype.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_writable_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter_nonconfigurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter_nonconfigurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwritable_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwritable_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_setter_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/descriptor.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/descriptor.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_property_exists.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_property_exists.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_getter_and_setter_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/length.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/length.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_writable_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_nonwritable_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_configurable_enumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_inherited_setter_configurable_enumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwriteable_nonconfigurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_nonwriteable_nonconfigurable_nonenumerable.js (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_configurable_nonenumerable.js [strict mode] (previously Failed)
test/built-ins/Object/hasOwn/hasown_own_getter_and_setter_configurable_nonenumerable.js (previously Failed)
test/built-ins/Object/prototype/hasOwnProperty/length.js [strict mode] (previously Failed)
test/built-ins/Object/prototype/hasOwnProperty/length.js (previously Failed)

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.

Nice work :)

@raskad raskad added this to the v0.14.0 milestone Oct 6, 2021
@raskad raskad added builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels Oct 6, 2021
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.

Good work! Just a small change I'd like to have to cover all cases of get_or_undefined

boa/src/builtins/object/mod.rs Outdated Show resolved Hide resolved
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.

Everything looks good. Great job!

@jedel1043 jedel1043 merged commit aaac3e9 into boa-dev:main Oct 7, 2021
@kevinputera kevinputera deleted the object-has-own branch October 7, 2021 02:41
@RageKnify RageKnify added the enhancement New feature or request label Jan 1, 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 execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement missing static Object methods
4 participants