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 Array.fromAsync #3725

Closed
68 of 70 tasks
Aditi-1400 opened this issue Nov 17, 2022 · 3 comments
Closed
68 of 70 tasks

Tests for Array.fromAsync #3725

Aditi-1400 opened this issue Nov 17, 2022 · 3 comments

Comments

@Aditi-1400
Copy link
Contributor

Aditi-1400 commented Nov 17, 2022

Proposal readme
Proposal Spec Text

Testing plan

  • Standard tests: Array.fromAsync: Boilerplate tests #3747

    • Property descriptor
    • Brand check - I think this covered by "this value is not a constructor" below
    • Function length
    • Function name
    • Not a constructor
    • Prototype and extensibility (blocked?)
  • Basic Functionality

  • Arguments

    • Input - Add tests for the asyncItems argument to Array.fromAsync. #3754

      • Invalid input values:

      • Valid inputs:

        • String
        • Sync-iterable with no promises
        • Sync-iterable with promises
        • Async-iterable
        • Non-iterable with no promises
        • Non-iterable with promises
        • @@asyncIterator returns sync iterator
      • Tests for input

        • Input array with boundary values

        • Covered by polyfill tests: - Add some Array.from async tests #3791

          • Output promise rejects if iteration of input fails
          • Output promise rejects if element access fails
          • Result promise rejects if input length exceeds safe integers seems impractical, tests time out
          • Awaits each input value once without mapping callback (with promises)
          • Result promise rejects if element's "then" method fails (with promises)
          • Result promise rejects if thenable element rejects (with promises)
          • Does not await input values (Async iterable)
          • Result promise rejects if length access fails (non-iterable input) - Array.fromAsync various remaining coverage #3809
          • Does not use array iterator prototype (non-iterable)
          • Unaffected by globalThis.Symbol mutation (non-iterable) - Array.fromAsync various remaining coverage #3809
    • Mapfn - Tests for mapfn and thisArg arguments to Array.fromAsync #3790

      • Invalid mapfn (Non callable)

        • null
        • {}
        • Valid string
        • Boolean
        • Number
        • Symbol
        • BigInt
      • Valid mapfn

        • Mapfn with sync callback
        • Mapfn with async callback
      • Tests for valid mapfn (All tests are covered in polyfill tests)

        • With default undefined this
        • With given thisValue
        • Output promise rejects if callback fails
        • Output promise rejects if mapfn is non callable
        • Awaits each input value once (with promises in input)
      • Tests for closing iterator and returned promise rejects

        • When mapFn completes abruptly
        • When mapFn returns a promise that rejects
    • ThisArg - Tests for mapfn and thisArg arguments to Array.fromAsync #3790

      • Mapfn without thisArg on non-strict mode
      • Mapfn without thisArg on strict mode
      • Mapfn with a valid thisArg
  • this value - Array.fromAsync various remaining coverage #3809

    • this value is a constructor
    • this value is not a constructor
    • Tests
      • If this is a constructor, and items doesn't have an @@iterator, returns a new instance of this
      • iterator closed when property creation on this fails
      • returned promise rejects when ^
  • Other Tests

Co-authored by: @Ms2ger @ptomato @cjtenny

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 18, 2022

Thanks @Aditi-1400!

FTR, a number of those tests are already written but need to get PRd

@tc39 tc39 deleted a comment Mar 17, 2023
ptomato added a commit to ptomato/test262 that referenced this issue Mar 31, 2023
This contains a few more tests for Array.fromAsync, in addition to what
has already been merged and what is under review at tc39#3791.

This covers the following items from the testing plan at tc39#3725:

- Success cases
  - Creates promise
  - Create new array/arraylike in promise (with length = length property)
- Input
  - Invalid input values
    - nonconforming object (arraylike without length, missing keys)
  - Covered by polyfill tests
    - Result promise rejects if length access fails (non-iterable input)
    - Unaffected by globalThis.Symbol mutation (non-iterable)
- this-value
  - this-value is a constructor
  - this-value is not a constructor
  - If this is a constructor, and items doesn't have a Symbol.iterator,
    returns a new instance of this
  - Iterator closed when property creation on this fails
  - Returned promise rejects when ^
- Other tests
  - Error is thrown for all CreateDataProperty fails
  - Non-writable properties are overwritten by CreateDataProperty
  - Input with missing values
ptomato added a commit to ptomato/test262 that referenced this issue Mar 31, 2023
This contains a few more tests for Array.fromAsync, in addition to what
has already been merged and what is under review at tc39#3791.

This covers the following items from the testing plan at tc39#3725:

- Success cases
  - Creates promise
  - Create new array/arraylike in promise (with length = length property)
- Input
  - Invalid input values
    - nonconforming object (arraylike without length, missing keys)
  - Covered by polyfill tests
    - Result promise rejects if length access fails (non-iterable input)
    - Unaffected by globalThis.Symbol mutation (non-iterable)
- this-value
  - this-value is a constructor
  - this-value is not a constructor
  - If this is a constructor, and items doesn't have a Symbol.iterator,
    returns a new instance of this
  - Iterator closed when property creation on this fails
  - Returned promise rejects when ^
- Other tests
  - Error is thrown for all CreateDataProperty fails
  - Non-writable properties are overwritten by CreateDataProperty
  - Input with missing values
ptomato added a commit to ptomato/test262 that referenced this issue Apr 4, 2023
This contains a few more tests for Array.fromAsync, in addition to what
has already been merged and what is under review at tc39#3791.

This covers the following items from the testing plan at tc39#3725:

- Success cases
  - Creates promise
  - Create new array/arraylike in promise (with length = length property)
- Input
  - Invalid input values
    - nonconforming object (arraylike without length, missing keys)
  - Covered by polyfill tests
    - Result promise rejects if length access fails (non-iterable input)
    - Unaffected by globalThis.Symbol mutation (non-iterable)
- this-value
  - this-value is a constructor
  - this-value is not a constructor
  - If this is a constructor, and items doesn't have a Symbol.iterator,
    returns a new instance of this
  - Iterator closed when property creation on this fails
  - Returned promise rejects when ^
- Other tests
  - Error is thrown for all CreateDataProperty fails
  - Non-writable properties are overwritten by CreateDataProperty
  - Input with missing values
ptomato added a commit to ptomato/test262 that referenced this issue Apr 4, 2023
This contains a few more tests for Array.fromAsync, in addition to what
has already been merged and what is under review at tc39#3791.

This covers the following items from the testing plan at tc39#3725:

- Success cases
  - Creates promise
  - Create new array/arraylike in promise (with length = length property)
- Input
  - Invalid input values
    - nonconforming object (arraylike without length, missing keys)
  - Covered by polyfill tests
    - Result promise rejects if length access fails (non-iterable input)
    - Unaffected by globalThis.Symbol mutation (non-iterable)
- this-value
  - this-value is a constructor
  - this-value is not a constructor
  - If this is a constructor, and items doesn't have a Symbol.iterator,
    returns a new instance of this
  - Iterator closed when property creation on this fails
  - Returned promise rejects when ^
- Other tests
  - Error is thrown for all CreateDataProperty fails
  - Non-writable properties are overwritten by CreateDataProperty
  - Input with missing values
Ms2ger pushed a commit to ptomato/test262 that referenced this issue Apr 4, 2023
This contains a few more tests for Array.fromAsync, in addition to what
has already been merged and what is under review at tc39#3791.

This covers the following items from the testing plan at tc39#3725:

- Success cases
  - Creates promise
  - Create new array/arraylike in promise (with length = length property)
- Input
  - Invalid input values
    - nonconforming object (arraylike without length, missing keys)
  - Covered by polyfill tests
    - Result promise rejects if length access fails (non-iterable input)
    - Unaffected by globalThis.Symbol mutation (non-iterable)
- this-value
  - this-value is a constructor
  - this-value is not a constructor
  - If this is a constructor, and items doesn't have a Symbol.iterator,
    returns a new instance of this
  - Iterator closed when property creation on this fails
  - Returned promise rejects when ^
- Other tests
  - Error is thrown for all CreateDataProperty fails
  - Non-writable properties are overwritten by CreateDataProperty
  - Input with missing values
Ms2ger added a commit that referenced this issue Apr 4, 2023
This contains a few more tests for Array.fromAsync, in addition to what
has already been merged and what is under review at #3791.

This covers the following items from the testing plan at #3725:

- Success cases
  - Creates promise
  - Create new array/arraylike in promise (with length = length property)
- Input
  - Invalid input values
    - nonconforming object (arraylike without length, missing keys)
  - Covered by polyfill tests
    - Result promise rejects if length access fails (non-iterable input)
    - Unaffected by globalThis.Symbol mutation (non-iterable)
- this-value
  - this-value is a constructor
  - this-value is not a constructor
  - If this is a constructor, and items doesn't have a Symbol.iterator,
    returns a new instance of this
  - Iterator closed when property creation on this fails
  - Returned promise rejects when ^
- Other tests
  - Error is thrown for all CreateDataProperty fails
  - Non-writable properties are overwritten by CreateDataProperty
  - Input with missing values

Co-authored-by: Ms2ger <[email protected]>
ptomato pushed a commit that referenced this issue Apr 7, 2023
This PR adds some more tests for Array.fromAsync proposal.
It includes most of the tests defined in https://github.com/es-shims/array-from-async/blob/main/test.mjs

See:#3725
@ptomato
Copy link
Contributor

ptomato commented Apr 7, 2023

There are two things left on the list:

  • Input array with boundary values
  • How much timing can we / do we need to test in terms of promise resolving?

I'm not sure what the idea is for the array with boundary values. My opinion about the second item is that we probably don't need to test the timing.

@Ms2ger
Copy link
Contributor

Ms2ger commented Apr 10, 2023

Let's say this is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants