Add missing tests where tostring throws TypeError #4884
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
{ 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.