mirror of
https://github.com/abue-ammar/tinycast.git
synced 2026-10-02 08:14:38 +08:00
Raycast 1.x import is gone: `RaycastImportV1`, `RaycastV1Decoder` and the `RaycastFormat` branch with it. With one format left, the V2 prefix says nothing, so `RaycastV2Decoder` is `RaycastDecoder` (now owning the RAYCFG3 signature and a passphrase-free `isExport`), and `RaycastImportV2` is `RaycastImportReader`, which absorbed the one-case `read` dispatcher. `RaycastImportError` moved to its own file so the harness compiles three sources instead of seven, and the category picker lost the disabled-row branch that only v1 needed. The comment pass applies docs/standards.md#comments to every Swift file: 397 stacked runs compressed to one line and 337 over-length comments cut to the 100-character cap, keeping the why and dropping the elaboration. Where a run carried two separate gotchas, the second moved to its own anchor rather than being lost. Comments that only restated their code are deleted outright.
79 lines
3.2 KiB
Swift
79 lines
3.2 KiB
Swift
import CoreGraphics
|
|
import Foundation
|
|
|
|
/// A row inside the band may not scroll; one behind the bottom bar must.
|
|
@main
|
|
@MainActor
|
|
struct SelectionRevealTests {
|
|
static var failures = 0
|
|
static var passes = 0
|
|
|
|
/// The palette's real proportions: a 369pt band between the bars, 36pt rows.
|
|
static let band: CGFloat = 369
|
|
static let rowHeight: CGFloat = 36
|
|
|
|
static func expect(
|
|
_ actual: SelectionReveal.Edge?, _ expected: SelectionReveal.Edge?, _ message: String
|
|
) {
|
|
if actual == expected {
|
|
passes += 1
|
|
} else {
|
|
failures += 1
|
|
print("FAIL: \(message) — got \(String(describing: actual)), want \(expected as Any)")
|
|
}
|
|
}
|
|
|
|
/// A row `rowHeight` tall whose top sits at `top`, the way a list row reports itself.
|
|
static func edge(rowTop top: CGFloat, height: CGFloat = rowHeight) -> SelectionReveal.Edge? {
|
|
SelectionReveal.edge(rowTop: top, rowBottom: top + height, band: band)
|
|
}
|
|
|
|
static func main() {
|
|
rowsInsideTheBandStayPut()
|
|
rowsPastAnEdgeAlignToIt()
|
|
theStripBehindTheBottomBar()
|
|
aRowTallerThanTheBand()
|
|
|
|
print("\(passes) passed, \(failures) failed")
|
|
if failures > 0 { exit(1) }
|
|
}
|
|
|
|
// MARK: - Leaving a visible row alone
|
|
|
|
static func rowsInsideTheBandStayPut() {
|
|
expect(edge(rowTop: 0), nil, "the first row at the band's top edge needs no scroll")
|
|
expect(edge(rowTop: 180), nil, "nor does a row in the middle")
|
|
expect(edge(rowTop: band - rowHeight), nil, "nor one flush with the bottom edge")
|
|
// Rounding must not churn: geometry arrives in fractional points.
|
|
expect(edge(rowTop: -0.3), nil, "a third of a point over the top edge is still inside")
|
|
expect(edge(rowTop: band - rowHeight + 0.3), nil, "and so is a third of a point under")
|
|
}
|
|
|
|
// MARK: - Moving a row that has left the band
|
|
|
|
static func rowsPastAnEdgeAlignToIt() {
|
|
expect(edge(rowTop: -1), .top, "a row a point above the band aligns to the top")
|
|
expect(edge(rowTop: -rowHeight), .top, "so does one scrolled a full row above it")
|
|
expect(edge(rowTop: -4000), .top, "and one far above, after a jump to the list's start")
|
|
expect(edge(rowTop: band - rowHeight + 1), .bottom, "a row a point below aligns to the bottom")
|
|
expect(edge(rowTop: band + 4000), .bottom, "and so does one far below it")
|
|
}
|
|
|
|
// MARK: - The strip the bug lived in
|
|
|
|
static func theStripBehindTheBottomBar() {
|
|
// Measured from the app: the band ends at 369, and 369…405 is visible but hidden.
|
|
expect(edge(rowTop: 369), .bottom, "the row that lands in the strip is moved into the band")
|
|
expect(edge(rowTop: 333), nil, "while the row flush above the strip is left alone")
|
|
}
|
|
|
|
// MARK: - Rows that cannot fit
|
|
|
|
static func aRowTallerThanTheBand() {
|
|
// Only its start can show, so aligning the top is the end state, not the start of a loop.
|
|
expect(edge(rowTop: 0, height: band + 100), nil, "a too-tall row pinned at the top is settled")
|
|
expect(edge(rowTop: -50, height: band + 100), .top, "one scrolled past its top is pulled back")
|
|
expect(edge(rowTop: 20, height: band + 100), .top, "and one hanging below the top is too")
|
|
}
|
|
}
|