Made File.Handle a non-copyable struct in the library to adopt Swift 6.4.
This commit is contained in:
@@ -345,6 +345,26 @@ struct WrapperTests {
|
||||
#expect(Mock.eventCount("close") == 1)
|
||||
}
|
||||
|
||||
@Test func jsonDecodeFileReadsThroughTheHandleAndClosesIt() throws {
|
||||
Mock.fileReadLimit = 5
|
||||
let value = try JSON.decodeFile(path: "save.json")
|
||||
guard case .null = value else {
|
||||
Issue.record("expected .null, got \(value)")
|
||||
return
|
||||
}
|
||||
#expect(Mock.events.contains("decode(5)"))
|
||||
#expect(Mock.eventCount("close") == 1)
|
||||
}
|
||||
|
||||
@Test func fileHandleClosesWhenItGoesOutOfScope() throws {
|
||||
do {
|
||||
let handle = try File.Handle(path: "save.dat", mode: .write)
|
||||
_ = try handle.write([1])
|
||||
#expect(Mock.eventCount("close") == 0)
|
||||
}
|
||||
#expect(Mock.eventCount("close") == 1)
|
||||
}
|
||||
|
||||
@Test func fileHandleReadLengthReturnsOnlyTheBytesRead() throws {
|
||||
let handle = try File.Handle(path: "save.dat", mode: [.read, .readData])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user