Skip to content

Test plan for Iterator.prototype.join #4697

@bakkot

Description

@bakkot

The iterator join proposal is at stage 2.7 (not to be confused with the joint iteration proposal, newly at stage 3).

I came up with this list of tests by thinking about it, and then looking at the tests for Array.prototype.join.

  • The usual boilerplate around name / length / enumerability / etc
  • Expected results when joining iterator length 0, 1, 2, 3 with no provided separator
  • As above but with a nonempty string as separator
  • As above but with empty string as separator
  • Throws if the receiver is not an object
  • Coerces the separator argument to string, including null or undefined
  • Coerces the iterator contents to string, except null and undefined
  • null and undefined from the iterator produce empty strings in the result
  • If ToString'ing the separator throws, the iterator gets closed
  • If ToString'ing a value from the iterator throws, the iterator gets closed
  • If the iterator throws, the iterator does not get closed
  • If the iterator otherwise violates the iterator protocol, e.g. by returning null from its next, the iterator does not get closed
  • If the iterator is exhausted, the iterator does not get closed
  • .next is looked up only after ToString'ing the separator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions