test(core): Swift oracle — the filius-ipad core built on Linux as the reference
tools/swift-oracle builds the unchanged Swift runtime (pinned 3b5ded0) in Docker and replays JSON scenarios; the TypeScript engine must produce the same trace events, results and end state. Five scenarios, 884 events, identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// Linux stand-in for the one call filius-ipad makes into Apple's Compression
|
||||
// framework: COMPRESSION_ZLIB is raw DEFLATE (RFC 1951), decoded here by zlib.
|
||||
import CZlib
|
||||
|
||||
public struct compression_algorithm: Equatable { let rawValue: Int32 }
|
||||
public let COMPRESSION_ZLIB = compression_algorithm(rawValue: 0x205)
|
||||
|
||||
public func compression_decode_buffer(
|
||||
_ dst: UnsafeMutablePointer<UInt8>, _ dstSize: Int,
|
||||
_ src: UnsafePointer<UInt8>, _ srcSize: Int,
|
||||
_ scratch: UnsafeMutableRawPointer?, _ algorithm: compression_algorithm
|
||||
) -> Int {
|
||||
var stream = z_stream()
|
||||
guard inflateInit2_(&stream, -15, ZLIB_VERSION, Int32(MemoryLayout<z_stream>.size)) == Z_OK else { return 0 }
|
||||
defer { inflateEnd(&stream) }
|
||||
stream.next_in = UnsafeMutablePointer(mutating: src)
|
||||
stream.avail_in = uInt(srcSize)
|
||||
stream.next_out = dst
|
||||
stream.avail_out = uInt(dstSize)
|
||||
let status = inflate(&stream, Z_FINISH)
|
||||
guard status == Z_STREAM_END || status == Z_OK || status == Z_BUF_ERROR else { return 0 }
|
||||
return Int(stream.total_out)
|
||||
}
|
||||
Reference in New Issue
Block a user