mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Update DebuggerSupport.swift
This commit is contained in:
@@ -148,8 +148,6 @@ public enum _DebuggerSupport {
|
|||||||
return count == 1 ? "1 element" : "\(count) elements"
|
return count == 1 ? "1 element" : "\(count) elements"
|
||||||
case .`struct`?, .`enum`?, nil:
|
case .`struct`?, .`enum`?, nil:
|
||||||
switch value {
|
switch value {
|
||||||
case let x as String:
|
|
||||||
return x.description
|
|
||||||
case let x as CustomDebugStringConvertible:
|
case let x as CustomDebugStringConvertible:
|
||||||
return x.debugDescription
|
return x.debugDescription
|
||||||
case let x as CustomStringConvertible:
|
case let x as CustomStringConvertible:
|
||||||
@@ -240,7 +238,13 @@ public enum _DebuggerSupport {
|
|||||||
print("\(name) : ", terminator: "", to: &target)
|
print("\(name) : ", terminator: "", to: &target)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let str = asStringRepresentation(value: value, mirror: mirror, count: count) {
|
if isRoot, let value = value as? String {
|
||||||
|
// We don't want to use string's debug desciprtion for 'po' because it
|
||||||
|
// escapes the string and prints it raw (e.g. prints "\n" instead of
|
||||||
|
// actually printing a newline), but only if its the root value. Otherwise,
|
||||||
|
// continue using the debug description.
|
||||||
|
print(value, terminator: "", to: &target)
|
||||||
|
} else if let str = asStringRepresentation(value: value, mirror: mirror, count: count) {
|
||||||
print(str, terminator: "", to: &target)
|
print(str, terminator: "", to: &target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ StringForPrintObjectTests.test("NSStringUTF8") {
|
|||||||
let debug = debugVal(&newNSUTF16)
|
let debug = debugVal(&newNSUTF16)
|
||||||
expectEqual("🏂☃❅❆❄︎⛄️❄️", String(reflecting: nsUTF16))
|
expectEqual("🏂☃❅❆❄︎⛄️❄️", String(reflecting: nsUTF16))
|
||||||
expectEqual("\"🏂☃❅❆❄︎⛄️❄️\"", String(reflecting: newNSUTF16))
|
expectEqual("\"🏂☃❅❆❄︎⛄️❄️\"", String(reflecting: newNSUTF16))
|
||||||
expectEqual("\"🏂☃❅❆❄︎⛄️❄️\"\n", printed)
|
expectEqual("🏂☃❅❆❄︎⛄️❄️\n", printed)
|
||||||
expectEqual(printed, debug)
|
expectEqual(printed, debug)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ StringForPrintObjectTests.test("DontBridgeThisStruct") {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if #available(SwiftStdlib 6.0, *) {
|
||||||
|
StringForPrintObjectTests.test("String") {
|
||||||
|
let printed = _stringForPrintObject("hello\nworld")
|
||||||
|
expectEqual(printed, "hello\nworld\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class RefCountedObj {
|
class RefCountedObj {
|
||||||
var patatino : Int
|
var patatino : Int
|
||||||
init(_ p : Int) {
|
init(_ p : Int) {
|
||||||
|
|||||||
Reference in New Issue
Block a user