File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
stdlib/private/StdlibUnittest Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ add_swift_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STD
15
15
# filename.
16
16
StdlibUnittest.swift.gyb
17
17
18
+ CheckStrideable.swift.gyb
18
19
InspectValue.cpp
19
20
InspectValue.swift
20
21
InterceptTraps.cpp
Original file line number Diff line number Diff line change
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See http://swift.org/LICENSE.txt for license information
9
+ // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ %{
14
+ from gyb_stdlib_unittest_support import TRACE, stackTrace, trace
15
+ }%
16
+
17
+ public func checkStrideable<S : Strideable>(
18
+ instances: [S],
19
+ distances: [S.Stride],
20
+ distanceOracle: (Int, Int) -> S.Stride,
21
+ ${TRACE}
22
+ ) {
23
+ for i in instances.indices {
24
+ let first = instances[i]
25
+ for j in instances.indices {
26
+ let second = instances[j]
27
+ expectEqual(distanceOracle(i, j), first.distance(to: second))
28
+ expectEqual(second, first.advanced(by: distanceOracle(i, j)))
29
+ }
30
+ }
31
+ }
32
+
You can’t perform that action at this time.
0 commit comments