Skip to content

Commit 1421970

Browse files
committed
Rebase after type rename
1 parent 6e75bbe commit 1421970

File tree

9 files changed

+26
-173
lines changed

9 files changed

+26
-173
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
public import Foundation
1414

1515
@_spi(Experimental)
16-
extension Test.Attachable where Self: Encodable & NSSecureCoding {
16+
extension Attachable where Self: Encodable & NSSecureCoding {
1717
@_documentation(visibility: private)
18-
public func withUnsafeBufferPointer<R>(for attachment: borrowing Test.Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
18+
public func withUnsafeBufferPointer<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
1919
try _Testing_Foundation.withUnsafeBufferPointer(encoding: self, for: attachment, body)
2020
}
2121
}

Sources/Overlays/_Testing_Foundation/Attachments/Test.Attachable+Encodable.swift renamed to Sources/Overlays/_Testing_Foundation/Attachments/Attachable+Encodable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private import Foundation
2626
///
2727
/// - Throws: Whatever is thrown by `body`, or any error that prevented the
2828
/// creation of the buffer.
29-
func withUnsafeBufferPointer<E, R>(encoding attachableValue: borrowing E, for attachment: borrowing Test.Attachment<E>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R where E: Test.Attachable & Encodable {
29+
func withUnsafeBufferPointer<E, R>(encoding attachableValue: borrowing E, for attachment: borrowing Attachment<E>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R where E: Attachable & Encodable {
3030
let format = try EncodingFormat(for: attachment)
3131

3232
let data: Data
@@ -53,7 +53,7 @@ func withUnsafeBufferPointer<E, R>(encoding attachableValue: borrowing E, for at
5353
// encoding to JSON. This lets developers provide trivial conformance to the
5454
// protocol for types that already support Codable.
5555
@_spi(Experimental)
56-
extension Test.Attachable where Self: Encodable {
56+
extension Attachable where Self: Encodable {
5757
/// Encode this value into a buffer using either [`PropertyListEncoder`](https://developer.apple.com/documentation/foundation/propertylistencoder)
5858
/// or [`JSONEncoder`](https://developer.apple.com/documentation/foundation/jsonencoder),
5959
/// then call a function and pass that buffer to it.
@@ -90,7 +90,7 @@ extension Test.Attachable where Self: Encodable {
9090
/// some other path extension, that path extension must represent a type
9191
/// that conforms to [`UTType.propertyList`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/propertylist)
9292
/// or to [`UTType.json`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/json).
93-
public func withUnsafeBufferPointer<R>(for attachment: borrowing Test.Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
93+
public func withUnsafeBufferPointer<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
9494
try _Testing_Foundation.withUnsafeBufferPointer(encoding: self, for: attachment, body)
9595
}
9696
}

Sources/Overlays/_Testing_Foundation/Attachments/Test.Attachable+NSSecureCoding.swift renamed to Sources/Overlays/_Testing_Foundation/Attachments/Attachable+NSSecureCoding.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public import Foundation
1616
// NSSecureCoding-conformant classes by default. The implementation uses
1717
// NSKeyedArchiver for encoding.
1818
@_spi(Experimental)
19-
extension Test.Attachable where Self: NSSecureCoding {
19+
extension Attachable where Self: NSSecureCoding {
2020
/// Encode this object using [`NSKeyedArchiver`](https://developer.apple.com/documentation/foundation/nskeyedarchiver)
2121
/// into a buffer, then call a function and pass that buffer to it.
2222
///
@@ -50,7 +50,7 @@ extension Test.Attachable where Self: NSSecureCoding {
5050
/// - Note: On Apple platforms, if the attachment's preferred name includes
5151
/// some other path extension, that path extension must represent a type
5252
/// that conforms to [`UTType.propertyList`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/propertylist).
53-
public func withUnsafeBufferPointer<R>(for attachment: borrowing Test.Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
53+
public func withUnsafeBufferPointer<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
5454
let format = try EncodingFormat(for: attachment)
5555

5656
var data = try NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: true)

Sources/Overlays/_Testing_Foundation/Attachments/Test.Attachment+URL.swift renamed to Sources/Overlays/_Testing_Foundation/Attachments/Attachment+URL.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ extension UTType {
4242
#endif
4343

4444
@_spi(Experimental)
45-
extension Test.Attachment where AttachableValue == Data {
45+
extension Attachment where AttachableValue == Data {
4646
/// Initialize an instance of this type with the contents of the given URL.
4747
///
4848
/// - Parameters:
4949
/// - url: The URL containing the attachment's data.
50-
/// - preferredName: The preferred name of the attachment when writing it
51-
/// to a test report or to disk. If `nil`, the name of the attachment is
50+
/// - preferredName: The preferred name of the attachment when writing it to
51+
/// a test report or to disk. If `nil`, the name of the attachment is
5252
/// derived from the last path component of `url`.
5353
/// - sourceLocation: The source location of the call to this initializer.
5454
/// This value is used when recording issues associated with the

Sources/Overlays/_Testing_Foundation/Attachments/Data+Test.Attachable.swift renamed to Sources/Overlays/_Testing_Foundation/Attachments/Data+Attachable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
public import Foundation
1414

1515
@_spi(Experimental)
16-
extension Data: Test.Attachable {
17-
public func withUnsafeBufferPointer<R>(for attachment: borrowing Test.Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
16+
extension Data: Attachable {
17+
public func withUnsafeBufferPointer<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
1818
try withUnsafeBytes(body)
1919
}
2020
}

Sources/Overlays/_Testing_Foundation/Attachments/EncodingFormat.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private import UniformTypeIdentifiers
1717
#endif
1818

1919
/// An enumeration describing the encoding formats we support for `Encodable`
20-
/// and `NSSecureCoding` types that conform to `Test.Attachable`.
20+
/// and `NSSecureCoding` types that conform to `Attachable`.
2121
enum EncodingFormat {
2222
/// A property list format.
2323
///
@@ -41,7 +41,7 @@ enum EncodingFormat {
4141
/// - attachment: The attachment that will be encoded.
4242
///
4343
/// - Throws: If the attachment's content type or media type is unsupported.
44-
init(for attachment: borrowing Test.Attachment<some Test.Attachable>) throws {
44+
init(for attachment: borrowing Attachment<some Attachable>) throws {
4545
let ext = (attachment.preferredName as NSString).pathExtension
4646

4747
#if SWT_TARGET_OS_APPLE && canImport(UniformTypeIdentifiers)

Sources/Testing/Attachments/Attachable.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,8 @@ extension Attachable where Self: Collection, Element == UInt8 {
8282
// We do not provide an implementation of withUnsafeBufferPointer(for:_:) here
8383
// because there is no way in the standard library to statically detect if a
8484
// collection can provide contiguous storage (_HasContiguousBytes is not API.)
85-
// If withContiguousBytesIfAvailable(_:) fails, we don't want to make a
85+
// If withContiguousStorageIfAvailable(_:) fails, we don't want to make a
8686
// (potentially expensive!) copy of the collection.
87-
//
88-
// The planned Foundation cross-import overlay can provide a default
89-
// implementation for collection types that conform to Foundation's
90-
// ContiguousBytes protocol.
9187
}
9288

9389
extension Attachable where Self: StringProtocol {

Sources/Testing/Attachments/Test.Attachable.swift

Lines changed: 0 additions & 143 deletions
This file was deleted.

Tests/TestingTests/AttachmentTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ struct AttachmentTests {
252252
}
253253

254254
await Test {
255-
let attachment = try await Test.Attachment(contentsOf: temporaryURL)
255+
let attachment = try await Attachment(contentsOf: temporaryURL)
256256
attachment.attach()
257257
}.run(configuration: configuration)
258258
}
@@ -280,7 +280,7 @@ struct AttachmentTests {
280280
}
281281

282282
await Test {
283-
let attachment = try await Test.Attachment(contentsOf: temporaryURL)
283+
let attachment = try await Attachment(contentsOf: temporaryURL)
284284
attachment.attach()
285285
}.run(configuration: configuration)
286286
}
@@ -290,7 +290,7 @@ struct AttachmentTests {
290290
@Test func attachUnsupportedContentsOfURL() async throws {
291291
let url = try #require(URL(string: "https://www.example.com"))
292292
await #expect(throws: CocoaError.self) {
293-
_ = try await Test.Attachment(contentsOf: url)
293+
_ = try await Attachment(contentsOf: url)
294294
}
295295
}
296296
#endif
@@ -361,7 +361,7 @@ struct AttachmentTests {
361361
name = "\(name).\(ext)"
362362
}
363363

364-
func open<T>(_ attachment: borrowing Test.Attachment<T>) throws where T: Test.Attachable {
364+
func open<T>(_ attachment: borrowing Attachment<T>) throws where T: Attachable {
365365
try attachment.attachableValue.withUnsafeBufferPointer(for: attachment) { bytes in
366366
#expect(bytes.first == args.firstCharacter.asciiValue)
367367
let decodedStringValue = try args.decode(Data(bytes))
@@ -371,19 +371,19 @@ struct AttachmentTests {
371371

372372
if args.forSecureCoding {
373373
let attachableValue = MySecureCodingAttachable(string: "stringly speaking")
374-
let attachment = Test.Attachment(attachableValue, named: name)
374+
let attachment = Attachment(attachableValue, named: name)
375375
try open(attachment)
376376
} else {
377377
let attachableValue = MyCodableAttachable(string: "stringly speaking")
378-
let attachment = Test.Attachment(attachableValue, named: name)
378+
let attachment = Attachment(attachableValue, named: name)
379379
try open(attachment)
380380
}
381381
}
382382

383383
@Test("Attach NSSecureCoding-conformant value but with a JSON type")
384384
func attachNSSecureCodingAsJSON() async throws {
385385
let attachableValue = MySecureCodingAttachable(string: "stringly speaking")
386-
let attachment = Test.Attachment(attachableValue, named: "loremipsum.json")
386+
let attachment = Attachment(attachableValue, named: "loremipsum.json")
387387
#expect(throws: CocoaError.self) {
388388
try attachment.attachableValue.withUnsafeBufferPointer(for: attachment) { _ in }
389389
}
@@ -392,7 +392,7 @@ struct AttachmentTests {
392392
@Test("Attach NSSecureCoding-conformant value but with a nonsensical type")
393393
func attachNSSecureCodingAsNonsensical() async throws {
394394
let attachableValue = MySecureCodingAttachable(string: "stringly speaking")
395-
let attachment = Test.Attachment(attachableValue, named: "loremipsum.gif")
395+
let attachment = Attachment(attachableValue, named: "loremipsum.gif")
396396
#expect(throws: CocoaError.self) {
397397
try attachment.attachableValue.withUnsafeBufferPointer(for: attachment) { _ in }
398398
}
@@ -491,11 +491,11 @@ struct MySendableAttachableWithDefaultByteCount: Attachable, Sendable {
491491
}
492492

493493
#if canImport(Foundation)
494-
struct MyCodableAttachable: Codable, Test.Attachable, Sendable {
494+
struct MyCodableAttachable: Codable, Attachable, Sendable {
495495
var string: String
496496
}
497497

498-
final class MySecureCodingAttachable: NSObject, NSSecureCoding, Test.Attachable, Sendable {
498+
final class MySecureCodingAttachable: NSObject, NSSecureCoding, Attachable, Sendable {
499499
let string: String
500500

501501
init(string: String) {
@@ -515,7 +515,7 @@ final class MySecureCodingAttachable: NSObject, NSSecureCoding, Test.Attachable,
515515
}
516516
}
517517

518-
final class MyCodableAndSecureCodingAttachable: NSObject, Codable, NSSecureCoding, Test.Attachable, Sendable {
518+
final class MyCodableAndSecureCodingAttachable: NSObject, Codable, NSSecureCoding, Attachable, Sendable {
519519
let string: String
520520

521521
static var supportsSecureCoding: Bool {

0 commit comments

Comments
 (0)