@@ -512,7 +512,7 @@ func checkSortedPredicateThrow(
512
512
}
513
513
}
514
514
515
- self . test ( " \( testNamePrefix) .sorted/DispatchesThrough_withUnsafeMutableBufferPointerIfSupported /WhereElementIsComparable " ) {
515
+ self . test ( " \( testNamePrefix) .sorted/DispatchesThroughDirectStorageAccessors /WhereElementIsComparable " ) {
516
516
let sequence = [ 5 , 4 , 3 , 2 , 1 ]
517
517
let elements : [ MinimalComparableValue ] =
518
518
zip ( sequence, 0 ..< sequence. count) . map {
@@ -525,13 +525,16 @@ self.test("\(testNamePrefix).sorted/DispatchesThrough_withUnsafeMutableBufferPoi
525
525
let result = lc. sorted ( )
526
526
let extractedResult = result. map ( extractValueFromComparable)
527
527
528
+ let actualWUMBPIF = lc. log. _withUnsafeMutableBufferPointerIfSupported [ type ( of: lc) ]
529
+ let actualWCMSIA = lc. log. withContiguousMutableStorageIfAvailable [ type ( of: lc) ]
530
+
531
+ let actualWUMBPIFNonNil = lc. log. _withUnsafeMutableBufferPointerIfSupportedNonNilReturns [ type ( of: lc) ]
532
+ let actualWCMSIANonNil = lc. log. withContiguousMutableStorageIfAvailableNonNilReturns [ type ( of: lc) ]
533
+
528
534
// This sort operation is not in-place.
529
535
// The collection is copied into an array before sorting.
530
- expectEqual (
531
- 0 , lc. log. _withUnsafeMutableBufferPointerIfSupported [ type ( of: lc) ] )
532
- expectEqual (
533
- 0 ,
534
- lc. log. _withUnsafeMutableBufferPointerIfSupportedNonNilReturns [ type ( of: lc) ] )
536
+ expectEqual ( 0 , actualWUMBPIF + actualWCMSIA)
537
+ expectEqual ( 0 , actualWUMBPIFNonNil + actualWCMSIANonNil)
535
538
536
539
expectEqualSequence ( [ 1 , 2 , 3 , 4 , 5 ] , extractedResult. map { $0. value } )
537
540
}
@@ -631,7 +634,7 @@ self.test("\(testNamePrefix).sorted/ThrowingPredicateWithLargeNumberElements") {
631
634
}
632
635
633
636
634
- self . test ( " \( testNamePrefix) .sorted/DispatchesThrough_withUnsafeMutableBufferPointerIfSupported /Predicate " ) {
637
+ self . test ( " \( testNamePrefix) .sorted/DispatchesThroughDirectStorageAccessors /Predicate " ) {
635
638
let sequence = [ 5 , 4 , 3 , 2 , 1 ]
636
639
let elements : [ OpaqueValue < Int > ] =
637
640
zip ( sequence, 0 ..< sequence. count) . map {
@@ -644,13 +647,16 @@ self.test("\(testNamePrefix).sorted/DispatchesThrough_withUnsafeMutableBufferPoi
644
647
let result = lc. sorted { extractValue ( $0) . value < extractValue ( $1) . value }
645
648
let extractedResult = result. map ( extractValue)
646
649
650
+ let actualWUMBPIF = lc. log. _withUnsafeMutableBufferPointerIfSupported [ type ( of: lc) ]
651
+ let actualWCMSIA = lc. log. withContiguousMutableStorageIfAvailable [ type ( of: lc) ]
652
+
653
+ let actualWUMBPIFNonNil = lc. log. _withUnsafeMutableBufferPointerIfSupportedNonNilReturns [ type ( of: lc) ]
654
+ let actualWUMBPIFNonNil = lc. log. withContiguousMutableStorageIfAvailableNonNilReturns [ type ( of: lc) ]
655
+
647
656
// This sort operation is not in-place.
648
657
// The collection is copied into an array before sorting.
649
- expectEqual (
650
- 0 , lc. log. _withUnsafeMutableBufferPointerIfSupported [ type ( of: lc) ] )
651
- expectEqual (
652
- 0 ,
653
- lc. log. _withUnsafeMutableBufferPointerIfSupportedNonNilReturns [ type ( of: lc) ] )
658
+ expectEqual ( 0 , actualWUMBPIF + actualWCMSIA)
659
+ expectEqual ( 0 , actualWUMBPIFNonNil + actualWUMBPIFNonNil)
654
660
655
661
expectEqualSequence ( [ 1 , 2 , 3 , 4 , 5 ] , extractedResult. map { $0. value } )
656
662
}
@@ -949,7 +955,7 @@ self.test("\(testNamePrefix).reverse()") {
949
955
// partition(by:)
950
956
//===----------------------------------------------------------------------===//
951
957
952
- self . test ( " \( testNamePrefix) .partition/DispatchesThrough_withUnsafeMutableBufferPointerIfSupported " ) {
958
+ self . test ( " \( testNamePrefix) .partition/DispatchesThroughDirectStorageAccessors " ) {
953
959
let sequence = [ 5 , 4 , 3 , 2 , 1 ]
954
960
let elements : [ OpaqueValue < Int > ] =
955
961
zip ( sequence, 0 ..< sequence. count) . map {
@@ -965,11 +971,23 @@ self.test("\(testNamePrefix).partition/DispatchesThrough_withUnsafeMutableBuffer
965
971
return !( extractValue ( val) . value < extractValue ( first!) . value)
966
972
} )
967
973
968
- expectEqual (
969
- 1 , lc. log. _withUnsafeMutableBufferPointerIfSupported [ type ( of: lc) ] )
974
+ let actualWUMBPIF = lc. log. _withUnsafeMutableBufferPointerIfSupported [ type ( of: lc) ]
975
+ let actualWCMSIA = lc. log. withContiguousMutableStorageIfAvailable [ type ( of: lc) ]
976
+
977
+ let actualWUMBPIFNonNil = lc. log. _withUnsafeMutableBufferPointerIfSupportedNonNilReturns [ type ( of: lc) ]
978
+ let actualWUMBPIFNonNil = lc. log. withContiguousMutableStorageIfAvailableNonNilReturns [ type ( of: lc) ]
979
+
980
+ expectEqual ( 1 , actualWUMBPIF + actualWCMSIA)
970
981
expectEqual (
971
982
withUnsafeMutableBufferPointerIsSupported ? 1 : 0 ,
972
- lc. log. _withUnsafeMutableBufferPointerIfSupportedNonNilReturns [ type ( of: lc) ] )
983
+ actualWUMBPIFNonNil + actualWUMBPIFNonNil)
984
+
985
+ if #available( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * ) {
986
+ // `partition(by:)` is expected to dispatch to the public API in releases
987
+ // that contain https://github.com/apple/swift/pull/36003.
988
+ expectEqual ( 0 , actualWUMBPIF)
989
+ expectEqual ( 0 , actualWUMBPIFNonNil)
990
+ }
973
991
974
992
expectEqual ( 4 , lc. distance ( from: lc. startIndex, to: pivot) )
975
993
expectEqualsUnordered ( [ 1 , 2 , 3 , 4 ] , lc. prefix ( upTo: pivot) . map { extractValue ( $0) . value } )
0 commit comments