Skip to content

Conversation

@G-Lee1031
Copy link
Contributor

Hello.
This PR adds tests covering two cases where ToString returns an abrupt completion. The changes are applied to String.prototype.at, String.prototype.indexOf, String.prototype.lastIndexOf

In all sections, the following two abrupt completion cases are tested:

  • When argument is a Symbol (throws TypeError).
  • When ToPrimitive returns an abrupt completion (specifically, by passing { valueOf: undefined, toString: undefined }) to trigger a throw in OrdinaryToPrimitive step 4).

String.prototype.at ( index )

This section covers ToString(O) called in String.prototype.at(index) step 2.

return-abrupt-from-this-tostring-symbol.js: Tests the Symbol case.
return-abrupt-from-this-tostring-toprimitive.js: Tests the ToPrimitive returning an abrupt completion case.

A similar test exists. However, it tests String.prototype.at step 1. So I named the files in a same format, but separated my code from the existing test.

String.prototype.indexOf ( searchString [ , position ] )

This section covers ToString(O) called in String.prototype.indexOf (searchString[ , position]) step 2.

this-value-tostring-symbol.js: Tests the Symbol case.
this-value-tostring-toprimitive.js: Tests the ToPrimitive returning an abrupt completion case.

String.prototype.lastIndexOf ( searchString [ , position ] )

This section covers ToString(O) called in String.prototype.lastIndexOf(searchString[,position]) step 2.

this-value-tostring-symbol.js: Tests the Symbol case.
this-value-tostring-toprimitive.js: Tests the ToPrimitive returning an abrupt completion case.

I apologize for the overlapping file names; my intention was to maintain a consistent naming convention. Please note that the uploaded files follow the exact same order as listed in the PR description, so reviewing them in that sequence should be helpful.

@G-Lee1031 G-Lee1031 requested a review from a team as a code owner January 23, 2026 06:44
@G-Lee1031 G-Lee1031 marked this pull request as draft January 23, 2026 07:03
@G-Lee1031 G-Lee1031 marked this pull request as ready for review January 23, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants