%import inspect %import os.path %import sys %sys.path = [os.path.split(inspect.getframeinfo(inspect.currentframe()).filename)[0] or '.'] + sys.path % Base = "%s%s%sCollection" % (base_kind, traversal, 'Mutable' if mutable else '') do { let prefix: [Int] = ${prefix} let suffix: [Int] = ${suffix} func makeCollection(elements: [OpaqueValue]) -> ${WrapperType}<${Base}>> { var baseElements = prefix.map(OpaqueValue.init) baseElements.appendContentsOf(elements) baseElements.appendContentsOf(suffix.map(OpaqueValue.init)) let base = ${Base}(elements: baseElements) let startIndex = base.startIndex.advancedBy(numericCast(prefix.count)) let endIndex = base.startIndex.advancedBy( numericCast(prefix.count + elements.count)) return ${WrapperType}( base: base, bounds: startIndex.. ${WrapperType}<${Base}> { var baseElements = prefix.map(MinimalEquatableValue.init) baseElements.appendContentsOf(elements) baseElements.appendContentsOf(suffix.map(MinimalEquatableValue.init)) let base = ${Base}(elements: baseElements) let startIndex = base.startIndex.advancedBy(numericCast(prefix.count)) let endIndex = base.startIndex.advancedBy( numericCast(prefix.count + elements.count)) return ${WrapperType}( base: base, bounds: startIndex.. ${WrapperType}<${Base}> { var baseElements = prefix.map(MinimalComparableValue.init) baseElements.appendContentsOf(elements) baseElements.appendContentsOf(suffix.map(MinimalComparableValue.init)) let base = ${Base}(elements: baseElements) let startIndex = base.startIndex.advancedBy(numericCast(prefix.count)) let endIndex = base.startIndex.advancedBy( numericCast(prefix.count + elements.count)) return ${WrapperType}( base: base, bounds: startIndex..> = Box([]) var resiliencyChecks = CollectionMisuseResiliencyChecks.all resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .ExpectationFailure resiliencyChecks.subscriptOnOutOfBoundsIndicesBehavior = .Trap resiliencyChecks.subscriptRangeOnOutOfBoundsRangesBehavior = .Trap SliceTests.add${traversal}${'Mutable' if WrapperType == 'MutableSlice' else ''}CollectionTests( "${name}.", makeCollection: makeCollection, wrapValue: identity, extractValue: identity, makeCollectionOfEquatable: makeCollectionOfEquatable, wrapValueIntoEquatable: identityEq, extractValueFromEquatable: identityEq, % if WrapperType == 'MutableSlice': makeCollectionOfComparable: makeCollectionOfComparable, wrapValueIntoComparable: identityComp, extractValueFromComparable: identityComp, % end checksAdded: checksAdded, resiliencyChecks: resiliencyChecks, outOfBoundsIndexOffset: 6 % if WrapperType == 'MutableSlice': , withUnsafeMutableBufferPointerIsSupported: false % end ) }