     wrapValue: (OpaqueValue<Int>) -> C.Iterator.Element,
     extractValue: (C.Iterator.Element) -> OpaqueValue<Int>,
 
-    makeCollectionOfEquatable: ([CollectionWithEquatableElement.Iterator.Element]) -> CollectionWithEquatableElement,
-    wrapValueIntoEquatable: (MinimalEquatableValue) -> CollectionWithEquatableElement.Iterator.Element,
-    extractValueFromEquatable: ((CollectionWithEquatableElement.Iterator.Element) -> MinimalEquatableValue),
+    makeCollectionOfEquatable: (
+      [CollectionWithEquatableElement.Iterator.Element]
+    ) -> CollectionWithEquatableElement,
+
+    wrapValueIntoEquatable: (
+      MinimalEquatableValue) -> CollectionWithEquatableElement.Iterator.Element,
+
+    extractValueFromEquatable: (
+      CollectionWithEquatableElement.Iterator.Element) -> MinimalEquatableValue,
 
     checksAdded: Box<Set<String>> = Box([]),
     resiliencyChecks: CollectionMisuseResiliencyChecks = .all,


    testNamePrefix += String(C.Type)

// FIXME: swift-3-indexing-model - add tests for the follow?
//          location(before: of i: Index) -> Index
//          formLocation(before: i: inout Index)

// FIXME: swift-3-indexing-model - enhance the following for negative direction?
//          advance(i: Index, by n: IndexDistance) -> Index
//          advance(i: Index, by n: IndexDistance, limitedBy: Index) -> Index
//          distance(from start: Index, to end: Index) -> IndexDistance

//===----------------------------------------------------------------------===//
// last
//===----------------------------------------------------------------------===//

self.test("\(testNamePrefix).last") {
  for test in subscriptRangeTests {
    let c = makeWrappedCollection(test.collection)
    let result = c.last
    if test.isEmpty {
      expectEmpty(result)
    } else {
      expectOptionalEqual(
        test.collection[test.count - 1],
        result.map(extractValue)
      ) { $0.value == $1.value }
    }
  }
}

//===----------------------------------------------------------------------===//
// removeLast()/slice
//===----------------------------------------------------------------------===//

self.test("\(testNamePrefix).removeLast()/slice/semantics") {
  for test in removeLastTests.filter({ $0.numberToRemove == 1 }) {
    let c = makeWrappedCollection(test.collection)
    var slice = c[c.startIndex..<c.endIndex]
    let survivingIndices = _allIndices(
      into: slice,
      in: slice.startIndex ..<
        slice.location(slice.endIndex, offsetBy: numericCast(-test.numberToRemove))
    )
    let removedElement = slice.removeLast()
    expectEqual(
      test.collection.last!.value,
      extractValue(removedElement).value)
    expectEqualSequence(
      test.expectedCollection,
      slice.map { extractValue($0).value },
      "removeLast() shouldn't mutate the head of the slice",
      stackTrace: SourceLocStack().with(test.loc)
    )
    expectEqualSequence(
      test.expectedCollection,
      survivingIndices.map { extractValue(slice[$0]).value },
      "removeLast() shouldn't invalidate indices",
      stackTrace: SourceLocStack().with(test.loc)
    )
    expectEqualSequence(
      test.collection.map { $0.value },
      c.map { extractValue($0).value },
      "removeLast() shouldn't mutate the collection that was sliced",
      stackTrace: SourceLocStack().with(test.loc))
  }
}

self.test("\(testNamePrefix).removeLast()/slice/empty/semantics") {
  let c = makeWrappedCollection(Array<OpaqueValue<Int>>())
  var slice = c[c.startIndex..<c.startIndex]
  expectCrashLater()
  _ = slice.removeLast() // Should trap.
}

//===----------------------------------------------------------------------===//
// removeLast(n: Int)/slice
//===----------------------------------------------------------------------===//

self.test("\(testNamePrefix).removeLast(n: Int)/slice/semantics") {
  for test in removeLastTests {
    let c = makeWrappedCollection(test.collection)
    var slice = c[c.startIndex..<c.endIndex]
    let survivingIndices = _allIndices(
      into: slice,
      in: slice.startIndex ..<
        slice.location(slice.endIndex, offsetBy: numericCast(-test.numberToRemove))
    )
    slice.removeLast(test.numberToRemove)
    expectEqualSequence(
      test.expectedCollection,
      slice.map { extractValue($0).value },
      "removeLast() shouldn't mutate the head of the slice",
      stackTrace: SourceLocStack().with(test.loc)
    )
    expectEqualSequence(
      test.expectedCollection,
      survivingIndices.map { extractValue(slice[$0]).value },
      "removeLast() shouldn't invalidate indices",
      stackTrace: SourceLocStack().with(test.loc)
    )
    expectEqualSequence(
      test.collection.map { $0.value },
      c.map { extractValue($0).value },
      "removeLast() shouldn't mutate the collection that was sliced",
      stackTrace: SourceLocStack().with(test.loc))
  }
}

self.test("\(testNamePrefix).removeLast(n: Int)/slice/empty/semantics") {
  let c = makeWrappedCollection(Array<OpaqueValue<Int>>())
  var slice = c[c.startIndex..<c.startIndex]
  expectCrashLater()
  slice.removeLast(1) // Should trap.
}

self.test("\(testNamePrefix).removeLast(n: Int)/slice/removeNegative/semantics") {
  let c = makeWrappedCollection([1010, 2020].map(OpaqueValue.init))
  var slice = c[c.startIndex..<c.startIndex]
  expectCrashLater()
  slice.removeLast(-1) // Should trap.
}

self.test("\(testNamePrefix).removeLast(n: Int)/slice/removeTooMany/semantics") {
  let c = makeWrappedCollection([1010, 2020].map(OpaqueValue.init))
  var slice = c[c.startIndex..<c.startIndex]
  expectCrashLater()
  slice.removeLast(3) // Should trap.
}

//===----------------------------------------------------------------------===//
// popLast()/slice
//===----------------------------------------------------------------------===//

self.test("\(testNamePrefix).popLast()/slice/semantics") {
  // This can just reuse the test data for removeLast()
  for test in removeLastTests.filter({ $0.numberToRemove == 1 }) {
    let c = makeWrappedCollection(test.collection)
    var slice = c[c.startIndex..<c.endIndex]
    let survivingIndices = _allIndices(
      into: slice,
      in: slice.startIndex ..<
        slice.location(slice.endIndex, offsetBy: numericCast(-test.numberToRemove))
    )
    let removedElement = slice.popLast()!
    expectEqual(
      test.collection.last!.value,
      extractValue(removedElement).value)
    expectEqualSequence(
      test.expectedCollection,
      slice.map { extractValue($0).value },
      "popLast() shouldn't mutate the head of the slice",
      stackTrace: SourceLocStack().with(test.loc)
    )
    expectEqualSequence(
      test.expectedCollection,
      survivingIndices.map { extractValue(slice[$0]).value },
      "popLast() shouldn't invalidate indices",
      stackTrace: SourceLocStack().with(test.loc)
    )
    expectEqualSequence(
      test.collection.map { $0.value },
      c.map { extractValue($0).value },
      "popLast() shouldn't mutate the collection that was sliced",
      stackTrace: SourceLocStack().with(test.loc))
  }
}

self.test("\(testNamePrefix).popLast()/slice/empty/semantics") {
  let c = makeWrappedCollection(Array<OpaqueValue<Int>>())
  var slice = c[c.startIndex..<c.startIndex]
  expectEmpty(slice.popLast())
}


//===----------------------------------------------------------------------===//
// Index
//===----------------------------------------------------------------------===//

if resiliencyChecks.creatingOutOfBoundsIndicesBehavior != .none {
  self.test("\(testNamePrefix).Index/OutOfBounds/Left/NonEmpty") {
    let c = makeWrappedCollection([ 1010, 2020, 3030 ].map(OpaqueValue.init))
    let index = c.startIndex
    expectCrashLater()
    _blackHole(c.location(index, offsetBy: numericCast(-outOfBoundsIndexOffset)))
  }

  self.test("\(testNamePrefix).Index/OutOfBounds/Left/Empty") {
    let c = makeWrappedCollection([])
    let index = c.startIndex
    expectCrashLater()
    _blackHole(c.location(index, offsetBy: numericCast(-outOfBoundsIndexOffset)))
  }
}

//===----------------------------------------------------------------------===//
// subscript(_: Index)
//===----------------------------------------------------------------------===//

if resiliencyChecks.subscriptOnOutOfBoundsIndicesBehavior != .none {
  self.test("\(testNamePrefix).subscript(_: Index)/OutOfBounds/Left/NonEmpty/Get") {
    let c = makeWrappedCollection([ 1010, 2020, 3030 ].map(OpaqueValue.init))
    var index = c.startIndex
    expectCrashLater()
    index = c.location(index, offsetBy: numericCast(-outOfBoundsSubscriptOffset))
    _blackHole(c[index])
  }

  self.test("\(testNamePrefix).subscript(_: Index)/OutOfBounds/Left/Empty/Get") {
    let c = makeWrappedCollection([])
    var index = c.startIndex
    expectCrashLater()
    index = c.location(index, offsetBy: numericCast(-outOfBoundsSubscriptOffset))
    _blackHole(c[index])
  }
}

//===----------------------------------------------------------------------===//
// subscript(_: Range)
//===----------------------------------------------------------------------===//

if resiliencyChecks.subscriptRangeOnOutOfBoundsRangesBehavior != .none {
  self.test("\(testNamePrefix).subscript(_: Range)/OutOfBounds/Left/NonEmpty/Get") {
    let c = makeWrappedCollection([ 1010, 2020, 3030 ].map(OpaqueValue.init))
    var index = c.startIndex
    expectCrashLater()
    index = c.location(index, offsetBy: numericCast(-outOfBoundsSubscriptOffset))
    _blackHole(c[index..<index])
  }

  self.test("\(testNamePrefix).subscript(_: Range)/OutOfBounds/Left/Empty/Get") {
    let c = makeWrappedCollection([])
    var index = c.startIndex
    expectCrashLater()
    index = c.location(index, offsetBy: numericCast(-outOfBoundsSubscriptOffset))
    _blackHole(c[index..<index])
  }
}

//===----------------------------------------------------------------------===//
// dropLast()
//===----------------------------------------------------------------------===//

self.test("\(testNamePrefix).dropLast/semantics") {
  for test in dropLastTests {
    let s = makeWrappedCollection(test.sequence.map(OpaqueValue.init))
    let result = s.dropLast(test.dropElements)
    expectEqualSequence(test.expected, result.map(extractValue).map { $0.value },
      stackTrace: SourceLocStack().with(test.loc))
  }
}

//===----------------------------------------------------------------------===//
// suffix()
//===----------------------------------------------------------------------===//

self.test("\(testNamePrefix).suffix/semantics") {
  for test in suffixTests {
    let s = makeWrappedCollection(test.sequence.map(OpaqueValue.init))
    let result = s.suffix(test.maxLength)
    expectEqualSequence(test.expected, result.map(extractValue).map { $0.value },
      stackTrace: SourceLocStack().with(test.loc))
  }
}

//===----------------------------------------------------------------------===//

  } // addBidirectionalCollectionTests


  public let position: Int
  public let expected: [Int]
  public let loc: SourceLoc
  
  init(
    collection: [Int], position: Int, expected: [Int],
    file: String = #file, line: UInt = #line
