Add more exhaustive tests for .asTypeOf (backport #4160) #4169
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.
This includes changing AsTypeOfSpec to be FunSpec instead of FlatSpec so that the tests can have more structure.
I'm working on making it possible to preserve literals across
.asTypeOf
casts (which will help with unit testing and is much more convenient for async reset). In doing so, I found the existing tests extremely lacking so I decided to lay out the existing behavior exhaustively. Please do not review this PR based on what you think should happen1, rather, treat this as documenting the existing behavior so that at least changes that should be functionally equivalent will be and we can be intentional in changing the behavior going forward.I marked this as documentation since, at least for development purposes, it is documenting the behavior.
Marked for backporting to 6.x since I want to backport the literal preservation as well.
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.Footnotes
All truncation should become an error when we get rid of implicit truncation and the "implicit extensions" for non-arithmetic types also should be an error, but that is obviously not the purpose of this PR.
This is an automatic backport of pull request Add more exhaustive tests for .asTypeOf #4160 done by Mergify. ↩