Added InlineArray pattern overloads to the library to optimize for macOS 26.
This commit is contained in:
@@ -64,6 +64,24 @@ struct WrapperTests {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])
|
||||
}
|
||||
|
||||
@Test func inlineArrayPatternMatchesTheTupleOne() throws {
|
||||
guard #available(macOS 26, *) else { return }
|
||||
// An array literal picks the InlineArray overload; a tuple literal
|
||||
// still picks the tuple one.
|
||||
let inline = Graphics.Pattern(rows: [1, 2, 3, 4, 5, 6, 7, 8])
|
||||
let tuple = Graphics.Pattern(rows: (1, 2, 3, 4, 5, 6, 7, 8))
|
||||
#expect(withUnsafeBytes(of: inline.bytes, Array.init)
|
||||
== withUnsafeBytes(of: tuple.bytes, Array.init))
|
||||
|
||||
Graphics.fillRect(x: 0, y: 0, width: 8, height: 8, color: .pattern(inline))
|
||||
#expect(Mock.patternBytes == [1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])
|
||||
|
||||
var pattern = inline
|
||||
pattern.inlineBytes[8] = 0x0f
|
||||
#expect(pattern.bytes.8 == 0x0f)
|
||||
}
|
||||
|
||||
@Test func drawTextSendsUTF8BytesAndLength() {
|
||||
let width = Graphics.drawText("Hëllo", x: 4, y: 6)
|
||||
#expect(Mock.events == ["drawText(Hëllo,enc:\(kUTF8Encoding.rawValue),4,6)"])
|
||||
@@ -121,6 +139,17 @@ struct WrapperTests {
|
||||
#expect(updated == [ObjectIdentifier(sprite)])
|
||||
}
|
||||
|
||||
@Test func spriteStencilPatternOverloadsSendTheSameRows() {
|
||||
let sprite = Sprite()
|
||||
sprite.setStencilPattern((1, 2, 3, 4, 5, 6, 7, 8))
|
||||
#expect(Mock.stencilRows == [1, 2, 3, 4, 5, 6, 7, 8])
|
||||
|
||||
guard #available(macOS 26, *) else { return }
|
||||
Mock.stencilRows = []
|
||||
sprite.setStencilPattern([1, 2, 3, 4, 5, 6, 7, 8])
|
||||
#expect(Mock.stencilRows == [1, 2, 3, 4, 5, 6, 7, 8])
|
||||
}
|
||||
|
||||
@Test func spriteIsFreedOnDeinitAndNotWhileReferenced() {
|
||||
var sprite: Sprite? = Sprite()
|
||||
_ = sprite
|
||||
|
||||
Reference in New Issue
Block a user