Skip to content

Commit e44fbdd

Browse files
author
Dave Abrahams
committed
isEquivalent: => by areEquivalent:
1 parent 90f9d72 commit e44fbdd

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ public func expectEqualSequence<
22282228
) where
22292229
Expected.Iterator.Element == Actual.Iterator.Element {
22302230

2231-
if !expected.elementsEqual(actual, isEquivalent: sameValue) {
2231+
if !expected.elementsEqual(actual, by: sameValue) {
22322232
expectationFailure("expected elements: \"\(expected)\"\n"
22332233
+ "actual: \"\(actual)\" (of type \(String(reflecting: actual.dynamicType)))",
22342234
trace: ${trace})

stdlib/public/core/SequenceAlgorithms.swift.gyb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ equivalenceExplanation = """\
3636
/// is, for any elements `a`, `b`, and `c`, the following conditions must
3737
/// hold:
3838
///
39-
/// - `isEquivalent(a, a)` is always `true`. (Reflexivity)
40-
/// - `isEquivalent(a, b)` implies `isEquivalent(b, a)`. (Symmetry)
41-
/// - If `isEquivalent(a, b)` and `isEquivalent(b, c)` are both `true`, then
42-
/// `isEquivalent(a, c)` is also `true`. (Transitivity)
39+
/// - `areEquivalent(a, a)` is always `true`. (Reflexivity)
40+
/// - `areEquivalent(a, b)` implies `areEquivalent(b, a)`. (Symmetry)
41+
/// - If `areEquivalent(a, b)` and `areEquivalent(b, c)` are both `true`, then
42+
/// `areEquivalent(a, c)` is also `true`. (Transitivity)
4343
///"""
4444

4545
}%
@@ -211,7 +211,7 @@ extension Sequence ${"" if preds else "where Iterator.Element : Equatable"} {
211211
${equivalenceExplanation}
212212
/// - Parameters:
213213
/// - possiblePrefix: A sequence to compare to this sequence.
214-
/// - isEquivalent: A predicate that returns `true` if its two arguments
214+
/// - areEquivalent: A predicate that returns `true` if its two arguments
215215
/// are equivalent; otherwise, `false`.
216216
/// - Returns: `true` if the initial elements of the sequence are equivalent
217217
/// to the elements of `possiblePrefix`; otherwise, `false`. Returns
@@ -237,12 +237,12 @@ ${equivalenceExplanation}
237237
/// the elements of `possiblePrefix`; otherwise, `false`. Returns `true`
238238
/// if `possiblePrefix` has no elements.
239239
///
240-
/// - SeeAlso: `starts(with:isEquivalent:)`
240+
/// - SeeAlso: `starts(with:by:)`
241241
% end
242242
public func starts<PossiblePrefix>(
243243
with possiblePrefix: PossiblePrefix${"," if preds else ""}
244244
% if preds:
245-
isEquivalent: @noescape (${GElement}, ${GElement}) throws -> Bool
245+
by areEquivalent: @noescape (${GElement}, ${GElement}) throws -> Bool
246246
% end
247247
) ${rethrows_}-> Bool
248248
where
@@ -252,7 +252,7 @@ ${equivalenceExplanation}
252252
var possiblePrefixIterator = possiblePrefix.makeIterator()
253253
for e0 in self {
254254
if let e1 = possiblePrefixIterator.next() {
255-
if ${"try !isEquivalent(e0, e1)" if preds else "e0 != e1"} {
255+
if ${"try !areEquivalent(e0, e1)" if preds else "e0 != e1"} {
256256
return false
257257
}
258258
}
@@ -287,10 +287,10 @@ extension Sequence ${"" if preds else "where Iterator.Element : Equatable"} {
287287
${equivalenceExplanation}
288288
/// - Parameters:
289289
/// - other: A sequence to compare to this sequence.
290-
/// - isEquivalent: A predicate that returns `true` if its two arguments
290+
/// - areEquivalent: A predicate that returns `true` if its two arguments
291291
/// are equivalent; otherwise, `false`.
292292
/// - Returns: `true` if this sequence and `other` contain equivalent items,
293-
/// using `isEquivalent` as the equivalence test; otherwise, `false.`
293+
/// using `areEquivalent` as the equivalence test; otherwise, `false.`
294294
///
295295
/// - SeeAlso: `elementsEqual(_:)`
296296
% else:
@@ -313,12 +313,12 @@ ${equivalenceExplanation}
313313
/// - Returns: `true` if this sequence and `other` contain the same elements
314314
/// in the same order.
315315
///
316-
/// - SeeAlso: `elementsEqual(_:isEquivalent:)`
316+
/// - SeeAlso: `elementsEqual(_:by:)`
317317
% end
318318
public func elementsEqual<OtherSequence>(
319319
_ other: OtherSequence${"," if preds else ""}
320320
% if preds:
321-
isEquivalent: @noescape (${GElement}, ${GElement}) throws -> Bool
321+
by areEquivalent: @noescape (${GElement}, ${GElement}) throws -> Bool
322322
% end
323323
) ${rethrows_}-> Bool
324324
where
@@ -330,7 +330,7 @@ ${equivalenceExplanation}
330330
while true {
331331
switch (iter1.next(), iter2.next()) {
332332
case let (e1?, e2?):
333-
if ${'try !isEquivalent(e1, e2)' if preds else 'e1 != e2'} {
333+
if ${'try !areEquivalent(e1, e2)' if preds else 'e1 != e2'} {
334334
return false
335335
}
336336
case (_?, nil),
@@ -694,7 +694,7 @@ extension Sequence {
694694
Builtin.unreachable()
695695
}
696696

697-
@available(*, unavailable, renamed: "starts(with:isEquivalent:)")
697+
@available(*, unavailable, renamed: "starts(with:by:)")
698698
public func startsWith<PossiblePrefix>(
699699
_ possiblePrefix: PossiblePrefix,
700700
isEquivalent: @noescape (Iterator.Element, Iterator.Element) throws -> Bool

test/1_stdlib/StringAPI.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ func checkHasPrefixHasSuffix(
240240
Array(String($0).unicodeScalars)
241241
}
242242
let expectHasPrefix = lhsNFDGraphemeClusters.starts(
243-
with: rhsNFDGraphemeClusters, isEquivalent: (==))
243+
with: rhsNFDGraphemeClusters, by: (==))
244244

245245
let expectHasSuffix = lhsNFDGraphemeClusters.lazy.reversed()
246-
.starts(with: rhsNFDGraphemeClusters.lazy.reversed(), isEquivalent: (==))
246+
.starts(with: rhsNFDGraphemeClusters.lazy.reversed(), by: (==))
247247

248248
expectEqual(expectHasPrefix, lhs.hasPrefix(rhs), stackTrace: stackTrace)
249249
expectEqual(
@@ -411,7 +411,7 @@ CStringTests.test("String(cString:)") {
411411
CStringTests.test("String.decodeCString") {
412412
do {
413413
let s = getNullCString()
414-
let result = String.decodeCString(UnsafePointer(s), `as`: UTF8.self)
414+
let result = String.decodeCString(UnsafePointer(s), as: UTF8.self)
415415
expectEmpty(result)
416416
}
417417
do { // repairing

test/IDE/complete_from_stdlib.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func testArchetypeReplacement3 (_ a : [Int]) {
166166
// PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super: dropLast({#(n): Int#})[#ArraySlice<Int>#]
167167
// PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super: dropFirst({#(n): Int#})[#AnySequence<Int>#]
168168
// PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super: prefix({#(maxLength): Int#})[#AnySequence<Int>#]
169-
// PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super: elementsEqual({#(other): Sequence#}, {#isEquivalent: (Int, Int) throws -> Bool##(Int, Int) throws -> Bool#})[' rethrows'][#Bool#]
169+
// PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super: elementsEqual({#(other): Sequence#}, {#by: (Int, Int) throws -> Bool##(Int, Int) throws -> Bool#})[' rethrows'][#Bool#]
170170

171171

172172
protocol P2 {

0 commit comments

Comments
 (0)