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

[Merged by Bors] - Implement Array.from #1831

Closed
wants to merge 2 commits into from

Conversation

nrabulinski
Copy link
Contributor

@nrabulinski nrabulinski commented Feb 9, 2022

This Pull Request fixes/closes #1784.

There're still a few tests failing, notably:

  • iter-set-elem-prop-non-writable - we don't have generator functions implemented
  • calling-from-valid-1-noStrict, iter-map-fn-this-non-strict - thisArg in non-strict mode, when undefined, should be inherited (that's what I'm guessing, I haven't confirmed this, but strict counterparts do pass with thisArg being undefined)
  • source-array-boundary, elements-deleted-after - Not sure yet, still investigating, but they also include thisArg, so perhaps function calling has an underlying issue? Failing because this on the top level evaluates to an empty object instead of containing everything from the top scope

@codecov
Copy link

codecov bot commented Feb 9, 2022

Codecov Report

Merging #1831 (d503142) into main (128f836) will decrease coverage by 0.11%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1831      +/-   ##
==========================================
- Coverage   45.98%   45.86%   -0.12%     
==========================================
  Files         206      206              
  Lines       17057    17097      +40     
==========================================
- Hits         7844     7842       -2     
- Misses       9213     9255      +42     
Impacted Files Coverage Δ
boa_engine/src/builtins/array/mod.rs 74.75% <0.00%> (-5.49%) ⬇️
boa_engine/src/builtins/iterable/mod.rs 49.01% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 128f836...d503142. Read the comment docs.

@jedel1043 jedel1043 added builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request labels Feb 10, 2022
@jedel1043 jedel1043 added this to the v0.14.0 milestone Feb 10, 2022
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.

Thank you for the contribution! I have some suggestions to improve the code, if you don't mind :)

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

Just got one tiny change, otherwise looks great!

boa/src/builtins/array/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

It looks pretty good! Thank you for the contribution :)

I added some comments, feel free to give them a look, but it's pretty good from my side!

boa/src/builtins/array/mod.rs Outdated Show resolved Hide resolved
boa/src/builtins/array/mod.rs Outdated Show resolved Hide resolved
@Razican
Copy link
Member

Razican commented Feb 23, 2022

@nrabulinski please, check the comments and see if you can fix what was mentioned, and re-base the branch, so that we can merge this as soon as possible :)

@HalidOdat
Copy link
Member

VM implementation

Test result main count PR count difference
Total 88,410 88,410 0
Passed 43,293 43,375 +82
Ignored 21,481 21,481 0
Failed 23,636 23,554 -82
Panics 0 0 0
Conformance 48.97% 49.06% +0.09%
Fixed tests (84):
test/built-ins/Array/from/source-object-length-set-elem-prop-non-writable.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-length-set-elem-prop-non-writable.js (previously Failed)
test/built-ins/Array/from/elements-added-after.js [strict mode] (previously Failed)
test/built-ins/Array/from/elements-added-after.js (previously Failed)
test/built-ins/Array/from/get-iter-method-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/get-iter-method-err.js (previously Failed)
test/built-ins/Array/from/iter-map-fn-this-non-strict.js (previously Failed)
test/built-ins/Array/from/elements-updated-after.js [strict mode] (previously Failed)
test/built-ins/Array/from/elements-updated-after.js (previously Failed)
test/built-ins/Array/from/Array.from-name.js [strict mode] (previously Failed)
test/built-ins/Array/from/Array.from-name.js (previously Failed)
test/built-ins/Array/from/array-like-has-length-but-no-indexes-with-values.js [strict mode] (previously Failed)
test/built-ins/Array/from/array-like-has-length-but-no-indexes-with-values.js (previously Failed)
test/built-ins/Array/from/source-array-boundary.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-array-boundary.js (previously Failed)
test/built-ins/Array/from/source-object-length.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-length.js (previously Failed)
test/built-ins/Array/from/source-object-missing.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-missing.js (previously Failed)
test/built-ins/Array/from/iter-get-iter-val-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-get-iter-val-err.js (previously Failed)
test/built-ins/Array/from/calling-from-valid-1-noStrict.js (previously Failed)
test/built-ins/Array/from/iter-map-fn-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-map-fn-err.js (previously Failed)
test/built-ins/Array/from/items-is-arraybuffer.js [strict mode] (previously Failed)
test/built-ins/Array/from/items-is-arraybuffer.js (previously Failed)
test/built-ins/Array/from/from-string.js [strict mode] (previously Failed)
test/built-ins/Array/from/from-string.js (previously Failed)
test/built-ins/Array/from/iter-cstm-ctor-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-cstm-ctor-err.js (previously Failed)
test/built-ins/Array/from/elements-deleted-after.js [strict mode] (previously Failed)
test/built-ins/Array/from/elements-deleted-after.js (previously Failed)
test/built-ins/Array/from/source-object-iterator-1.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-iterator-1.js (previously Failed)
test/built-ins/Array/from/iter-map-fn-this-strict.js [strict mode] (previously Failed)
test/built-ins/Array/from/from-array.js [strict mode] (previously Failed)
test/built-ins/Array/from/from-array.js (previously Failed)
test/built-ins/Array/from/this-null.js [strict mode] (previously Failed)
test/built-ins/Array/from/this-null.js (previously Failed)
test/built-ins/Array/from/iter-set-elem-prop.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-set-elem-prop.js (previously Failed)
test/built-ins/Array/from/iter-map-fn-args.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-map-fn-args.js (previously Failed)
test/built-ins/Array/from/calling-from-valid-1-onlyStrict.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-constructor.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-constructor.js (previously Failed)
test/built-ins/Array/from/Array.from-descriptor.js [strict mode] (previously Failed)
test/built-ins/Array/from/Array.from-descriptor.js (previously Failed)
test/built-ins/Array/from/iter-map-fn-this-arg.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-map-fn-this-arg.js (previously Failed)
test/built-ins/Array/from/source-object-iterator-2.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-iterator-2.js (previously Failed)
test/built-ins/Array/from/Array.from_arity.js [strict mode] (previously Failed)
test/built-ins/Array/from/Array.from_arity.js (previously Failed)
test/built-ins/Array/from/iter-get-iter-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-get-iter-err.js (previously Failed)
test/built-ins/Array/from/iter-map-fn-return.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-map-fn-return.js (previously Failed)
test/built-ins/Array/from/calling-from-valid-2.js [strict mode] (previously Failed)
test/built-ins/Array/from/calling-from-valid-2.js (previously Failed)
test/built-ins/Array/from/iter-adv-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-adv-err.js (previously Failed)
test/built-ins/Array/from/mapfn-throws-exception.js [strict mode] (previously Failed)
test/built-ins/Array/from/mapfn-throws-exception.js (previously Failed)
test/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js [strict mode] (previously Failed)
test/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js (previously Failed)
test/built-ins/Array/from/iter-cstm-ctor.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-cstm-ctor.js (previously Failed)
test/built-ins/Array/from/iter-set-elem-prop-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-set-elem-prop-err.js (previously Failed)
test/built-ins/Array/from/iter-set-elem-prop-non-writable.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-set-elem-prop-non-writable.js (previously Failed)
test/built-ins/Array/from/iter-set-length-err.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-set-length-err.js (previously Failed)
test/built-ins/Array/from/iter-set-length.js [strict mode] (previously Failed)
test/built-ins/Array/from/iter-set-length.js (previously Failed)
test/built-ins/Array/from/source-object-without.js [strict mode] (previously Failed)
test/built-ins/Array/from/source-object-without.js (previously Failed)
test/built-ins/Proxy/apply/trap-is-undefined-target-is-proxy.js [strict mode] (previously Failed)
test/built-ins/Proxy/apply/trap-is-undefined-target-is-proxy.js (previously Failed)
test/built-ins/TypedArray/prototype/sort/stability.js [strict mode] (previously Failed)
test/built-ins/TypedArray/prototype/sort/stability.js (previously Failed)
test/harness/deepEqual-mapset.js [strict mode] (previously Failed)
test/harness/deepEqual-mapset.js (previously Failed)
Broken tests (2):
test/annexB/built-ins/Array/from/iterator-method-emulates-undefined.js [strict mode] (previously Passed)
test/annexB/built-ins/Array/from/iterator-method-emulates-undefined.js (previously Passed)

boa_engine/src/builtins/array/mod.rs Outdated Show resolved Hide resolved
boa_engine/src/builtins/array/mod.rs Outdated Show resolved Hide resolved
@jedel1043 jedel1043 changed the title Implemented Array.from Implement Array.from Mar 7, 2022
@Razican
Copy link
Member

Razican commented Mar 10, 2022

@nrabulinski it would be nice to get this merged during the weekend, for the 0.14 release of Boa. Do you have time to check the comments by @jedel1043?

nrabulinski and others added 2 commits March 12, 2022 16:48
- Make `IfAbruptCloseIterator` a pub(crate) macro since it's used in more places in the spec.
Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

The comments have been 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.

No more nitpicks :)

@Razican
Copy link
Member

Razican commented Mar 12, 2022

bors r+

bors bot pushed a commit that referenced this pull request Mar 12, 2022
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->

This Pull Request fixes/closes #1784.

There're still a few tests failing, notably:
- `iter-set-elem-prop-non-writable` - we don't have generator functions implemented
- `calling-from-valid-1-noStrict`, `iter-map-fn-this-non-strict` - `thisArg` in non-strict mode, when undefined, should be inherited (that's what I'm guessing, I haven't confirmed this, but strict counterparts do pass with `thisArg` being `undefined`)
- `source-array-boundary`, `elements-deleted-after` - ~~Not sure yet, still investigating, but they also include thisArg, so perhaps function calling has an underlying issue?~~ Failing because `this` on the top level evaluates to an empty object instead of containing everything from the top scope

Co-authored-by: HalidOdat <halidodat@gmail.com>
@bors
Copy link

bors bot commented Mar 12, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Implement Array.from [Merged by Bors] - Implement Array.from Mar 12, 2022
@bors bors bot closed this Mar 12, 2022
Razican pushed a commit that referenced this pull request Jun 8, 2022
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->

This Pull Request fixes/closes #1784.

There're still a few tests failing, notably:
- `iter-set-elem-prop-non-writable` - we don't have generator functions implemented
- `calling-from-valid-1-noStrict`, `iter-map-fn-this-non-strict` - `thisArg` in non-strict mode, when undefined, should be inherited (that's what I'm guessing, I haven't confirmed this, but strict counterparts do pass with `thisArg` being `undefined`)
- `source-array-boundary`, `elements-deleted-after` - ~~Not sure yet, still investigating, but they also include thisArg, so perhaps function calling has an underlying issue?~~ Failing because `this` on the top level evaluates to an empty object instead of containing everything from the top scope

Co-authored-by: HalidOdat <halidodat@gmail.com>
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.

Implement Array.from(arrayLike, mapFn)
5 participants