[test] Adjust new Substring test #29446
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.
This fixes the new Substring test that checks for the behavioral change introduced in #29094/#29146.
We don't have a good way to test exactly what version of the stdlib we're running on, so it isn't feasible to write two-way tests for behavior that is expected to change between stdlib versions. The
if #available(9999)
checks we have now will fail when we run these tests on a future released version of the stdlib that includes these changes. Even worse, the expected behavior on older stdlibs depends on whether the method is called in a Sequence-generic context. (The implementation is marked@_alwaysEmitIntoClient
, so client code that directly calls it will have the new behavior; however, the Sequence witness table for Substring will still point to the default implementation in old stdlibs.)Therefore, if the availability test fails, we cannot tell which behavior we need to expect, so we must stop checking for it.
On the other hand, if the availability check succeeds, then we are guaranteed to have a new stdlib -- so we need to look at the expected behavior in that case, and only that case.
rdar://58868606