[stdlibUnittest, 6.2] generalize expectNil(_:)
#82703
Merged
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.
Explanation:
Generalize StdlibUnittest's expectNil(_:) function for non-copyable and non-escapable parameter types. Useful for testing failable UTF8Span initializers, for example.
This generalization adds an overload, because simply generalizing would remove functionality. The original version prints an unexpected value using string interpolation. The string interpolation machinery cannot handle a non-escapable or non-copyable parameter value yet, so we instead add a version that can handle such values but does not print. Merging these is left for future work.
Resolves: rdar://154522348 (by unbreaking the 32-bit testing path)
Risk: Low. Makes more code possible, and is source-compatible with the previously-existing function.
Main branch PR: #82701
Review by: @stephentyrone
Testing: added specific test, and existing tests show source-compatibility.