mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[validation-test] Extracting array and slice types conformance tests
Since these tests take the most time, spliting them into 'one type - one conformance' pairs to maximize parallelism. <rdar://problem/30269532>
This commit is contained in:
@@ -376,109 +376,4 @@ for (step, evilBoundsCheck) in [ (1, true), (-1, false), (-1, true) ] {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func ArraySliceWithNonZeroStartIndex<T>(_ elements: [T]) -> ArraySlice<T> {
|
||||
var r = ArraySlice<T>(_startIndex: 1000)
|
||||
r.append(contentsOf: elements)
|
||||
expectEqual(1000, r.startIndex)
|
||||
return r
|
||||
}
|
||||
|
||||
% for array_type in all_array_types + ['ArraySliceWithNonZeroStartIndex']:
|
||||
% collection_or_slice = 'Slice' if 'Slice' in array_type else 'Collection'
|
||||
|
||||
do {
|
||||
// `Array`, `ArraySlice`, and `ContiguousArrayBuffer` have no expectation of
|
||||
// failure for advancing their indexes "out of bounds", because they are just
|
||||
// `Int`.
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
// Test MutableCollectionType conformance with value type elements.
|
||||
ArrayTestSuite.addMutableRandomAccessCollectionTests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with reference type elements.
|
||||
ArrayTestSuite.addMutableRandomAccessCollectionTests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in
|
||||
LifetimeTracked(element.value, identity: element.identity)
|
||||
},
|
||||
extractValue: { (element: LifetimeTracked) in
|
||||
OpaqueValue(element.value, identity: element.identity)
|
||||
},
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with value type elements.
|
||||
ArrayTestSuite.addRangeReplaceableRandomAccess${collection_or_slice}Tests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with reference type elements.
|
||||
ArrayTestSuite.addRangeReplaceableRandomAccess${collection_or_slice}Tests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in LifetimeTracked(element.value) },
|
||||
extractValue: { (element: LifetimeTracked) in OpaqueValue(element.value) },
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
}
|
||||
|
||||
% end
|
||||
|
||||
runAllTests()
|
||||
|
||||
Reference in New Issue
Block a user