mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Removing the “checksAdded” parameter from collection unit tests and simply sharing a global variable is a better way to go. We don't use threads at that level, so there's no thread safety issue, and we already committed to globals when we introduced the logging wrappers.
89 lines
3.3 KiB
Swift
89 lines
3.3 KiB
Swift
// -*- swift -*-
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Automatically Generated From validation-test/stdlib/Collection/Inputs/Template.swift.gyb
|
|
// Do Not Edit Directly!
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: %S/../../../utils/gyb %s -o %t/main.swift
|
|
// RUN: %S/../../../utils/line-directive %t/main.swift -- %target-build-swift %t/main.swift -o %t/MinimalMutableRandomAccessCollection.swift.a.out
|
|
// RUN: %S/../../../utils/line-directive %t/main.swift -- %target-run %t/MinimalMutableRandomAccessCollection.swift.a.out
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
import StdlibCollectionUnittest
|
|
|
|
// Also import modules which are used by StdlibUnittest internally. This
|
|
// workaround is needed to link all required libraries in case we compile
|
|
// StdlibUnittest with -sil-serialize-all.
|
|
import SwiftPrivate
|
|
#if _runtime(_ObjC)
|
|
import ObjectiveC
|
|
#endif
|
|
|
|
var CollectionTests = TestSuite("Collection")
|
|
|
|
// Test collections using value types as elements.
|
|
do {
|
|
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
|
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .trap
|
|
|
|
CollectionTests.addMutableRandomAccessCollectionTests(
|
|
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
|
return MinimalMutableRandomAccessCollection(elements: elements)
|
|
},
|
|
wrapValue: identity,
|
|
extractValue: identity,
|
|
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
|
return MinimalMutableRandomAccessCollection(elements: elements)
|
|
},
|
|
wrapValueIntoEquatable: identityEq,
|
|
extractValueFromEquatable: identityEq,
|
|
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
|
return MinimalMutableRandomAccessCollection(elements: elements)
|
|
},
|
|
wrapValueIntoComparable: identityComp,
|
|
extractValueFromComparable: identityComp,
|
|
resiliencyChecks: resiliencyChecks
|
|
, withUnsafeMutableBufferPointerIsSupported: false,
|
|
isFixedLengthCollection: true
|
|
)
|
|
}
|
|
|
|
// Test collections using a reference type as element.
|
|
do {
|
|
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
|
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .trap
|
|
|
|
CollectionTests.addMutableRandomAccessCollectionTests(
|
|
makeCollection: { (elements: [LifetimeTracked]) in
|
|
return MinimalMutableRandomAccessCollection(elements: 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 MinimalMutableRandomAccessCollection(elements: elements)
|
|
},
|
|
wrapValueIntoEquatable: identityEq,
|
|
extractValueFromEquatable: identityEq,
|
|
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
|
// FIXME: use LifetimeTracked.
|
|
return MinimalMutableRandomAccessCollection(elements: elements)
|
|
},
|
|
wrapValueIntoComparable: identityComp,
|
|
extractValueFromComparable: identityComp,
|
|
resiliencyChecks: resiliencyChecks
|
|
, withUnsafeMutableBufferPointerIsSupported: false,
|
|
isFixedLengthCollection: true
|
|
)
|
|
}
|
|
|
|
runAllTests()
|