Skip to content

Commit ffe4eda

Browse files
Max MoiseevCodaFi
authored andcommitted
Addressing PR comments and updating some tests
1 parent e5864b2 commit ffe4eda

10 files changed

+31
-20
lines changed

stdlib/private/StdlibCollectionUnittest/CheckCollectionType.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ extension TestSuite {
561561
return makeCollectionOfEquatable(elements.map(wrapValueIntoEquatable))
562562
}
563563

564-
testNamePrefix += String(C.Type.self)
564+
testNamePrefix += String(describing: C.Type.self)
565565

566566
//===------------------------------------------------------------------===//
567567
// generate()
@@ -1209,7 +1209,7 @@ extension TestSuite {
12091209
return makeCollection(elements.map(wrapValue))
12101210
}
12111211

1212-
testNamePrefix += String(C.Type.self)
1212+
testNamePrefix += String(describing: C.Type.self)
12131213

12141214
// FIXME: swift-3-indexing-model - add tests for the follow?
12151215
// index(before: of i: Index) -> Index
@@ -1522,7 +1522,7 @@ extension TestSuite {
15221522

15231523
addBidirectionalCollectionTests(${forwardTestArgs})
15241524

1525-
testNamePrefix += String(C.Type.self)
1525+
testNamePrefix += String(describing: C.Type.self)
15261526

15271527
func makeWrappedCollection(_ elements: [OpaqueValue<Int>]) -> C {
15281528
return makeCollection(elements.map(wrapValue))

stdlib/private/StdlibCollectionUnittest/CheckMutableCollectionType.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ extension TestSuite {
148148
return makeCollectionOfComparable(elements.map(wrapValueIntoComparable))
149149
}
150150

151-
testNamePrefix += String(C.Type.self)
151+
testNamePrefix += String(describing: C.Type.self)
152152

153153
//===----------------------------------------------------------------------===//
154154
// subscript(_: Index)
@@ -749,7 +749,7 @@ self.test("\(testNamePrefix).partition/InvalidOrderings") {
749749
return makeCollection(elements.map(wrapValue))
750750
}
751751

752-
testNamePrefix += String(C.Type.self)
752+
testNamePrefix += String(describing: C.Type.self)
753753

754754
//===----------------------------------------------------------------------===//
755755
// subscript(_: Index)
@@ -906,7 +906,7 @@ self.test("\(testNamePrefix).partition/DispatchesThrough_withUnsafeMutableBuffer
906906
return makeCollectionOfComparable(elements.map(wrapValueIntoComparable))
907907
}
908908

909-
testNamePrefix += String(C.Type.self)
909+
testNamePrefix += String(describing: C.Type.self)
910910

911911
//===----------------------------------------------------------------------===//
912912
// sort()

stdlib/private/StdlibCollectionUnittest/CheckRangeReplaceableCollectionType.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ extension TestSuite {
497497
return makeCollection(elements.map(wrapValue))
498498
}
499499

500-
testNamePrefix += String(C.Type.self)
500+
testNamePrefix += String(describing: C.Type.self)
501501

502502
//===----------------------------------------------------------------------===//
503503
// init()
@@ -1218,7 +1218,7 @@ self.test("\(testNamePrefix).OperatorPlus") {
12181218
return makeCollection(elements.map(wrapValue))
12191219
}
12201220

1221-
testNamePrefix += String(C.Type.self)
1221+
testNamePrefix += String(describing: C.Type.self)
12221222

12231223
//===----------------------------------------------------------------------===//
12241224
// removeLast()
@@ -1340,7 +1340,7 @@ self.test("\(testNamePrefix).removeLast(n: Int)/whereIndexIsBidirectional/remove
13401340
resiliencyChecks: resiliencyChecks,
13411341
outOfBoundsIndexOffset: outOfBoundsIndexOffset)
13421342

1343-
testNamePrefix += String(C.Type.self)
1343+
testNamePrefix += String(describing: C.Type.self)
13441344

13451345
// No extra checks for collections with random access traversal so far.
13461346
} // addRangeReplaceableRandomAccessCollectionTests

stdlib/private/StdlibCollectionUnittest/CheckRangeReplaceableSliceType.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extension TestSuite {
6565
return makeCollection(elements.map(wrapValue))
6666
}
6767

68-
testNamePrefix += String(C.Type.self)
68+
testNamePrefix += String(describing: C.Type.self)
6969

7070
//===------------------------------------------------------------------===//
7171
// removeFirst()
@@ -210,7 +210,7 @@ extension TestSuite {
210210
return makeCollection(elements.map(wrapValue))
211211
}
212212

213-
testNamePrefix += String(C.Type.self)
213+
testNamePrefix += String(describing: C.Type.self)
214214

215215
//===------------------------------------------------------------------===//
216216
// removeLast()
@@ -351,7 +351,7 @@ extension TestSuite {
351351
resiliencyChecks: resiliencyChecks,
352352
outOfBoundsIndexOffset: outOfBoundsIndexOffset)
353353

354-
testNamePrefix += String(C.Type.self)
354+
testNamePrefix += String(describing: C.Type.self)
355355

356356
// No tests yet.
357357
} // addRangeReplaceableRandomAccessSliceTests

stdlib/private/StdlibCollectionUnittest/CheckSequenceType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ extension TestSuite {
14841484
return makeSequenceOfEquatable(elements.map(wrapValueIntoEquatable))
14851485
}
14861486

1487-
testNamePrefix += String(S.Type.self)
1487+
testNamePrefix += String(describing: S.Type.self)
14881488

14891489
let isMultiPass = makeSequence([])
14901490
._preprocessingPass { true } ?? false

stdlib/public/core/Integers.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ public protocol SignedInteger_ : BinaryInteger, SignedArithmetic {
688688

689689
extension SignedInteger_ {
690690
public var description: String {
691-
let base = String(magnitude)
691+
let base = String(describing: magnitude)
692692
return self < 0 ? "-" + base : base
693693
}
694694

stdlib/public/core/OutputStream.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,17 @@ public protocol CustomStringConvertible {
164164
var description: String { get }
165165
}
166166

167+
/// A type that can be represented as a string in a lossless, unambiguous way.
168+
///
169+
/// For example, the integer value 1050 can be represented in its entirety as
170+
/// the string "1050".
171+
///
172+
/// The description property of a conforming type must be a value-preserving
173+
/// representation of the original value. As such, it should be possible to
174+
/// attempt to re-create an instance from its string representation.
167175
public protocol LosslessStringConvertible : CustomStringConvertible {
176+
/// Instantiates an instance of the conforming type from a string
177+
/// representation.
168178
init?(_ description: String)
169179
}
170180

stdlib/public/core/StaticString.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public struct StaticString
255255

256256
extension StaticString {
257257
public var customMirror: Mirror {
258-
return Mirror(reflecting: String(describing: self))
258+
return Mirror(reflecting: description)
259259
}
260260
}
261261

stdlib/public/core/String.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,10 @@ extension String {
982982
#endif
983983
}
984984

985-
public // @testable
986-
init<T: LosslessStringConvertible>(_ v: T) {
987-
self = v.description
985+
/// Creates an instance from the description of a given
986+
/// LosslessStringConvertible instance.
987+
public init<T : LosslessStringConvertible>(_ value: T) {
988+
self = value.description
988989
}
989990
}
990991

stdlib/public/core/UnicodeScalar.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ extension UnicodeScalar : LosslessStringConvertible {
287287
if let v = UInt32(description) where (v < 0xD800 || v > 0xDFFF)
288288
&& v <= 0x10FFFF {
289289
self = UnicodeScalar(v)
290+
} else {
291+
return nil
290292
}
291-
292-
return nil
293293
}
294294
}
295295

0 commit comments

Comments
 (0)