feat(ui): 实现全卡堆叠趋势与单页资源进程布局

This commit is contained in:
2026-11-15 17:59:52 +08:00
parent 469766892d
commit 99e558625b
37 changed files with 579 additions and 195 deletions
+8 -2
View File
@@ -10,14 +10,14 @@ import SwiftUI
precondition(last > 0 && first - last <= 1)
let columns = rows.max()!
let cellWidth = (width - Double(columns - 1) * 3) / Double(columns)
precondition(cellWidth >= 8, "Each real core needs its own visible meter cell")
precondition(cellWidth >= 6, "Each real core needs its own visible meter cell")
}
}
}
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 430) == [18])
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 280) == [18])
precondition(CPUCoreGridLayout.rowCounts(count: 32, width: 430) == [32])
precondition(CPUCoreGridLayout.rowCounts(count: 48, width: 430) == [24, 24])
precondition(CPUCoreGridLayout.rowCounts(count: 48, width: 430) == [48])
for count in [0, 1, 4, 8, 14, 18, 24, 32, 48, 128] {
let kinds = Dictionary(uniqueKeysWithValues: (0..<count).map { ($0, $0 < count / 3 ? CPUCoreTopology.Kind.efficiency : .performance) })
let groups = CPUCoreGrid.groups(count: count, kinds: kinds)
@@ -26,6 +26,7 @@ import SwiftUI
let widths = CPUCoreGrid.groupWidths(groups: groups, width: width)
precondition(widths.allSatisfy { $0 >= 0 && $0.isFinite })
precondition(widths.allSatisfy { $0 <= width })
if !groups.isEmpty { precondition(abs(widths.reduce(0, +) + Double(groups.count - 1) * 8 - width) < 1e-9) }
for (group, groupWidth) in zip(groups, widths) {
let rows = CPUCoreGridLayout.rowCounts(count: group.count, width: groupWidth)
precondition(rows.reduce(0, +) == group.count)
@@ -36,6 +37,11 @@ import SwiftUI
precondition(CPUCoreGridLayout.rowCounts(count: 128, width: width).reduce(0, +) == 128)
}
precondition(CPUCoreGrid.groups(count: 3, kinds: [0: .efficiency]).count == 2)
precondition(SegmentedCoreBar.portions(0) == [0,0,0,0])
precondition(SegmentedCoreBar.portions(0.125) == [0.5,0,0,0])
precondition(SegmentedCoreBar.portions(0.5) == [1,1,0,0])
precondition(SegmentedCoreBar.portions(1) == [1,1,1,1])
for invalid: Double? in [nil,.nan,-1] { precondition(SegmentedCoreBar.portions(invalid) == [0,0,0,0]) }
print("PASS: compact per-core meters with intact identities and bounded wrapping at multiple widths/counts")
}
}
+6 -6
View File
@@ -13,17 +13,17 @@ import Foundation
store.setPanelVisible(true)
try await until { store.history.samples.count >= 2 }
precondition(probe.count == 0 && store.processSnapshot == nil && store.energy == nil,
"Overview must not enumerate processes or publish process power")
store.setDetailDemand(processes: true, slowMetrics: false)
"Disabled process demand must not enumerate processes or publish process power")
store.setDetailDemand(processes: true, slowMetrics: true)
try await until { probe.count > 0 }
// Withdraw demand while the synchronous OS read still holds the single slot.
store.setDetailDemand(processes: false, slowMetrics: true)
try await Task.sleep(for: .milliseconds(350))
precondition(store.processSnapshot == nil, "A completion from the previous page must not publish")
precondition(store.processSnapshot == nil, "A completion from the withdrawn demand must not publish")
let stopped = probe.count
try await Task.sleep(for: .milliseconds(650))
precondition(probe.count == stopped && store.snapshot.cpu != nil)
store.setDetailDemand(processes: true, slowMetrics: false)
store.setDetailDemand(processes: true, slowMetrics: true)
try await until { store.processSnapshot != nil }
precondition(probe.peak == 1)
precondition(store.history.samples.dropFirst().allSatisfy { !$0.breakBefore && $0.cpu != nil },
@@ -32,7 +32,7 @@ import Foundation
precondition(store.processSnapshot == nil && store.energy == nil)
store.togglePause()
let pausedCount = store.history.samples.count
store.setDetailDemand(processes: true, slowMetrics: false)
store.setDetailDemand(processes: true, slowMetrics: true)
try await Task.sleep(for: .milliseconds(650))
precondition(store.history.samples.count == pausedCount && store.processSnapshot == nil)
store.togglePause()
@@ -40,7 +40,7 @@ import Foundation
store.setPanelVisible(false)
precondition(store.processSnapshot == nil && store.energy == nil)
store.togglePause()
print("PASS: overview performs no process reads, page withdrawal rejects stale completion, single in-flight read, continuous base history and pause/hidden precedence")
print("PASS: disabled demand performs no process reads, unified demand supports both details, withdrawal rejects stale completion, single in-flight read, continuous base history and pause/hidden precedence")
}
@MainActor private static func until(_ condition: () -> Bool) async throws {
+12 -1
View File
@@ -10,7 +10,18 @@ import Foundation
precondition(CPUTemperatureMonitor.decodeSensorNumber(type: 0, bytes: []) == nil)
precondition(FanMetrics.validRPM(0) == 0)
for value in [Double.nan, .infinity, -1, 30_001] { precondition(FanMetrics.validRPM(value) == nil) }
print("PASS: fan decoding, invalid RPM and static indicator data")
for (rpm, speed) in [(1.0,90.0), (1999,90), (2000,180), (3999,180), (4000,300), (5999,300), (6000,450)] {
precondition(FanRotation.speed(rpm: rpm, reducedMotion: false) == speed)
precondition(FanRotation.speed(rpm: rpm, reducedMotion: true) == 0)
}
var rotation = FanRotation()
rotation.update(rpm: 1000, reducedMotion: false, at: 10)
precondition(rotation.angle(at: 11) == 90)
rotation.update(rpm: 3000, reducedMotion: false, at: 11)
precondition(rotation.angle(at: 11) == 90 && rotation.angle(at: 12) == 270)
rotation.update(rpm: 0, reducedMotion: false, at: 12)
precondition(rotation.angle(at: 100) == 270)
print("PASS: fan decoding, invalid RPM, historical speed boundaries and continuous phase")
print("Live fan RPM:", CPUTemperatureMonitor().sampleFans() as Any)
}
}
+36
View File
@@ -0,0 +1,36 @@
import AppKit
import SwiftUI
@main struct FanRotorChecks {
@MainActor static func main() {
_ = NSApplication.shared; NSApp.setActivationPolicy(.accessory)
Task { @MainActor in
let window = NSWindow(contentRect: NSRect(x: 30, y: 30, width: 40, height: 40), styleMask: [.borderless], backing: .buffered, defer: false)
window.isReleasedWhenClosed = false
let rotor = FanRotor.RotorView(); rotor.frame = NSRect(x: 4, y: 4, width: 20, height: 20)
window.contentView!.addSubview(rotor); window.orderFrontRegardless()
try? await Task.sleep(for: .milliseconds(100))
for (rpm, duration) in [(1000.0,4.0),(2000,2),(4000,1.2),(6000,0.8)] {
rotor.configure(rpm: rpm, active: true, reducedMotion: false)
precondition(abs(rotor.layer!.animation(forKey: FanRotor.RotorView.animationKey)!.duration - duration) < 1e-9)
}
for rpm: Double? in [0,nil,.nan,-1] {
rotor.configure(rpm: rpm, active: true, reducedMotion: false)
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
}
rotor.configure(rpm: 3000, active: true, reducedMotion: false)
precondition(rotor.layer!.animationKeys()?.isEmpty == false)
rotor.configure(rpm: 3000, active: false, reducedMotion: false)
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
rotor.configure(rpm: 3000, active: true, reducedMotion: true)
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
rotor.configure(rpm: 3000, active: true, reducedMotion: false)
rotor.removeFromSuperview()
precondition(rotor.layer!.animationKeys()?.isEmpty != false, "Detached fans must stop rotating")
window.orderOut(nil); window.close()
print("PASS: native rotor speed tiers, nil/zero/invalid readings, inactive/reduced motion and detach stop")
NSApp.terminate(nil)
}
NSApp.run()
}
}
+31 -1
View File
@@ -99,10 +99,40 @@ import QuartzCore
plot.configure(.init(frame: PanelCurveFrame(dates: dates, series: [[nil,nil,nil,nil], [0.5,0.5,0.5,0.5]],
intervals: [2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5))
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) > 10)
// Distinct cumulative bands must meet at 30%, with 70% total at the full plot scale.
var stack = NativePanelCurve.Input(frame: .init(dates: dates,
series: [Array(repeating: 0.3, count: 4), Array(repeating: 0.4, count: 4)],
intervals: [2,2,2,2], boundaryDates: []), colors: [.red,.blue], scales: [1], maximumGap: 5,
filledSeriesCount: 2, stacked: true)
plot.configure(stack)
let upperArea = (plot.curves.sublayers![1].sublayers![0] as! CAShapeLayer).path!.boundingBoxOfPath
precondition(abs(upperArea.minY - 18) < 1e-9 && abs(upperArea.maxY - 42) < 1e-9,
"The upper component must fill only between cumulative boundaries")
let stackedBitmap = bitmap(plot)
var redBand = 0, blueBand = 0
for y in 0..<stackedBitmap.pixelsHigh {
let c = stackedBitmap.colorAt(x: stackedBitmap.pixelsWide / 2, y: y)!.usingColorSpace(.deviceRGB)!
guard c.alphaComponent > 0.1 && c.alphaComponent < 0.18 else { continue }
if c.redComponent > c.blueComponent + 0.2 { redBand += 1 }
if c.blueComponent > c.redComponent + 0.2 { blueBand += 1 }
}
precondition(redBand > 20 && blueBand > 30, "Both components must produce separate translucent area pixels")
let stackedBuilds = plot.pathBuildCount
stack.hoveredIndex = 1; plot.configure(stack)
let cumulativeDot = plot.layer!.sublayers!.last as! CAShapeLayer
precondition(abs(cumulativeDot.path!.boundingBoxOfPath.midY - 18) < 1e-9)
precondition(plot.pathBuildCount == stackedBuilds)
stack = .init(frame: .init(dates: dates,
series: [Array(repeating: 0.3, count: 4), Array(repeating: 0.4, count: 4)],
intervals: [2,2,2,2], boundaryDates: [dates[2]]), colors: [.red,.blue], scales: [1], maximumGap: 5,
filledSeriesCount: 2, stacked: true)
plot.configure(stack)
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) == 0,
"Every stack band must respect the same real sampling break")
assertStatic(plot.layer!)
plot.removeFromSuperview()
window.orderOut(nil); window.close()
print("PASS: static background lines/area pixels, no single-point fill, hidden-series isolation, immediate stable updates, no animation/material/gradient layers, real gaps, hover cache, palette growth, appearance, full history and unmount")
print("PASS: stacked component pixels and cumulative hover, static background lines/area pixels, no single-point fill, hidden-series isolation, immediate stable updates, no animation/material/gradient layers, real gaps, hover cache, palette growth, appearance, full history and unmount")
fflush(stdout); NSApp.terminate(nil)
}
NSApp.run()
+24 -21
View File
@@ -3,7 +3,7 @@ import CoreGraphics
@main struct PanelLayoutChecks {
static func main() {
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 648, height: 448))
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 648, height: 630))
for visible in [CGRect(x: 0, y: 67, width: 1512, height: 882), CGRect(x: -1440, y: -200, width: 1440, height: 800), CGRect(x: 0, y: 24, width: 800, height: 600)] {
let content = PanelLayout.contentSize(visible: visible, chrome: CGSize(width: 4, height: 12))
precondition(content.width + 4 <= visible.width - 32 && content.height + 12 <= visible.height - 32)
@@ -14,7 +14,7 @@ import CoreGraphics
precondition(visible.insetBy(dx: 16, dy: 16).contains(centered))
}
}
let compact = PanelLayout.cardHeights(coreRows: 2, fanCount: 2)
let compact = PanelLayout.cardHeights(coreRows: 1, fanCount: 2)
precondition(PanelLayout.cardRows(columns: 3) == [[.cpu, .gpu, .memory], [.battery, .storage, .network]])
precondition(PanelLayout.cardRows(columns: 2) == [[.cpu, .gpu], [.memory, .battery], [.storage, .network]])
precondition(PanelLayout.cardRows(columns: 1) == PanelCard.allCases.map { [$0] })
@@ -29,39 +29,42 @@ import CoreGraphics
for (row, height) in zip(rows, PanelLayout.rowHeights(columns: columns, heights: compact)) {
precondition(row.allSatisfy { (compact[$0] ?? 0) <= height }, "Every card must fit its aligned row")
}
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 400), heights: compact))
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 2400), heights: compact))
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: width, height: 400), heights: compact))
precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: width, height: 2400), heights: compact))
}
precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [176, 176])
precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [176, 176, 176])
precondition(PanelLayout.cardWidth(size: CGSize(width: 648, height: 448)) == ResourceCardMetrics.preferredWidth,
precondition(PanelLayout.cardWidth(size: CGSize(width: 648, height: 630)) == ResourceCardMetrics.preferredWidth,
"Three columns must retain readable card widths")
precondition(PanelLayout.preferredHeight(width: 648, heights: compact) == 448)
precondition(PanelLayout.preferredHeight(width: 520, heights: compact) == 662)
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 448), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 447), heights: compact))
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 520, height: 662), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 520, height: 661), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 360, height: 800), heights: compact))
precondition(PanelLayout.preferredHeight(width: 648, heights: compact) == 630)
precondition(PanelLayout.preferredHeight(width: 520, heights: compact) == 800)
precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 630), heights: compact))
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 629), heights: compact))
precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: 520, height: 812), heights: compact))
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 520, height: 811), heights: compact))
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 360, height: 800), heights: compact))
precondition(PanelLayout.columns(width: 648) == 3 && PanelLayout.columns(width: 620) == 3)
precondition(PanelLayout.columns(width: 619) == 2 && PanelLayout.columns(width: 430) == 2 && PanelLayout.columns(width: 429) == 1)
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [232, 176],
"Extra CPU rows must grow the first grid row without changing the second")
let moreFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 10)
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [346, 346],
"All resource rows must share the maximum structural card height")
let moreFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 10)
precondition(moreFans[.gpu]! > compact[.gpu]! && moreFans[.storage] == compact[.storage])
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [232, 176])
let noFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 0)
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [232, 232])
let noFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 0)
precondition(noFans[.gpu] == 176 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [176, 176])
precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 448,
precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 630,
"A fanless GPU must keep row alignment with CPU and memory")
precondition(PanelLayout.cardHeights(coreRows: 2, fanCount: nil) == compact,
precondition(PanelLayout.cardHeights(coreRows: 1, fanCount: nil) == compact,
"Discovery placeholders must reserve the ordinary fan row")
let manyCores = PanelLayout.cardHeights(coreRows: 30, fanCount: 10)
precondition(PanelLayout.preferredHeight(width: 648, heights: manyCores) == 800)
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 800), heights: manyCores))
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 800), heights: manyCores))
let requested = PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900), preferredHeight: 732)
precondition(requested.height == 732, "A hardware-driven height above the default must be preserved")
precondition(PanelLayout.processHeight(heights: compact) == 176)
precondition(PanelLayout.dashboardHeight(columns: 3, heights: compact) == 540)
precondition(PanelLayout.processHeight(heights: tallerCPU) == 346)
let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in
let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0)
let path: String? = index == 42 ? "/test/needle" : nil
@@ -89,6 +92,6 @@ import CoreGraphics
}
let pidSorted = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .pid)], order: [])
precondition(pidSorted.first?.id.pid == 2000)
print("PASS: three-column/two-row grid, aligned hardware-driven row heights, responsive reading order, scroll and screen limits, column breakpoints, width conservation, visible-frame bounds/chrome/negative origins, 2000-row CPU/footprint projection, frozen order, path search and empty results")
print("PASS: three-column resource grid plus equal-height process row, aligned hardware-driven row heights, responsive reading order, scroll and screen limits, column breakpoints, width conservation, visible-frame bounds/chrome/negative origins, 2000-row CPU/footprint projection, frozen order, path search and empty results")
}
}
-2
View File
@@ -43,7 +43,6 @@ import SwiftUI
// Geometry reports and centering run on subsequent main-queue turns.
try? await Task.sleep(for: .milliseconds(200))
controller.presentation.isPinned = true
controller.presentation.page = .processes
let cover = NSWindow(contentRect: controller.panel.frame.insetBy(dx: -8, dy: -8),
styleMask: [.borderless], backing: .buffered, defer: false)
cover.isReleasedWhenClosed = false
@@ -75,7 +74,6 @@ import SwiftUI
precondition(!controller.panel.isVisible && !visible)
controller.togglePanel()
precondition(controller.panel.isVisible && visible)
precondition(controller.presentation.page == .overview, "Explicit reopening must select overview")
controller.statusMenu().performActionForItem(at: 1)
precondition(settingsRequests == 1 && !controller.panel.isVisible)
controller.show()
+44
View File
@@ -0,0 +1,44 @@
import AppKit
import SwiftUI
/// Verify the production section fills its assigned row even when the scope note wraps.
@main struct ProcessSectionChecks {
@MainActor static func main() {
_ = NSApplication.shared; NSApp.setActivationPolicy(.accessory)
Task { @MainActor in
let window = NSWindow(contentRect: NSRect(x: 30, y: 30, width: 628, height: 176),
styleMask: [.borderless], backing: .buffered, defer: false)
window.isReleasedWhenClosed = false; window.level = .floating
let host = NSHostingView(rootView: AnyView(EmptyView())); host.sizingOptions = []
window.contentView = host; window.orderFrontRegardless()
let rows = (0..<100).map { ProcessMetrics(id: .init(pid: Int32($0 + 1), seconds: 1, microseconds: 0),
name: "worker-\($0)", path: "/fixture/worker", cpu: 0.1, footprintBytes: 1 << 20, threads: 2, restricted: false) }
let snapshot = ProcessSnapshot(date: Date(), enumerated: 100, readable: 100, rows: rows, failed: false)
let energy = ProcessEnergySnapshot(date: Date(), candidates: 100, readable: 100, rows: [], state: .available)
for dark in [false,true] {
window.appearance = NSAppearance(named: dark ? .darkAqua : .aqua)
for language in ["zh-Hans","zh-Hant","en"] {
for width: CGFloat in [340,628] {
window.setContentSize(NSSize(width: width, height: 176))
host.rootView = AnyView(ProcessTableView(snapshot: snapshot, energy: energy, state: ProcessTableState())
.environment(\.locale, Locale(identifier: language))
.environment(\.colorScheme, dark ? .dark : .light))
try? await Task.sleep(for: .milliseconds(100)); host.layoutSubtreeIfNeeded()
let scrolls = descendants(host).compactMap { $0 as? NSScrollView }.filter { $0.documentView is NSTableView }
precondition(scrolls.count == 1)
let scroll = scrolls[0], rect = scroll.convert(scroll.bounds, to: host)
let topRect = host.isFlipped ? rect : CGRect(x: rect.minX, y: host.bounds.height - rect.maxY, width: rect.width, height: rect.height)
precondition(abs(topRect.maxY - 166) < 1 && topRect.height > 75,
"The native table must fill the equal-height row down to its 10pt inset: \(language), \(width), \(topRect)")
precondition(abs(topRect.minX - 10) < 1 && abs(topRect.maxX - (width - 10)) < 1)
}
}
}
host.rootView = AnyView(EmptyView()); window.orderOut(nil); window.close()
print("PASS: production process section at 176pt, wrapped scope notes, full remaining table height, two widths, three languages and light/dark")
NSApp.terminate(nil)
}
NSApp.run()
}
@MainActor private static func descendants(_ view: NSView) -> [NSView] { [view] + view.subviews.flatMap(descendants) }
}
+6 -6
View File
@@ -27,14 +27,14 @@ import SwiftUI
precondition(plots.count == 1)
let plot = plots[0]
precondition(abs(host.bounds.width - width) < 1, "AppKit may round fractional content sizes to a point")
precondition(abs(plot.bounds.width - host.bounds.width) < 0.5 && plot.bounds.height == 48,
"The background chart must occupy the full card width, without axes or plot insets")
precondition(abs(plot.bounds.width - host.bounds.width) < 0.5 && abs(plot.bounds.height - host.bounds.height) < 0.5,
"The background chart must occupy the full card width and height, without axes or plot insets")
let graph = topRect(plot, in: host)
precondition(abs(graph.maxY - host.bounds.height) < 0.5,
precondition(abs(graph.minY) < 0.5 && abs(graph.maxY - host.bounds.height) < 0.5,
"The background chart must end at the card bottom")
let detail = topRect(probe.view!, in: host)
precondition(detail.maxY <= graph.minY + 0.5 && detail.width <= host.bounds.width - 20 + 0.5,
"Foreground details must stay above the graph, including narrow/localized cards")
precondition(detail.minY >= 0 && detail.maxY <= host.bounds.height && detail.width <= host.bounds.width - 20 + 0.5,
"Foreground details must overlay the full-height graph within card bounds, including narrow/localized cards")
precondition(plot.grid.isHidden && plot.input?.visibleSeriesCount == 1)
}
}
@@ -64,7 +64,7 @@ import SwiftUI
try? await Task.sleep(for: .milliseconds(100))
precondition(descendants(host).allSatisfy { !($0 is NativePanelCurve.PlotView) })
window.orderOut(nil); window.contentView = nil; window.close()
print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, foreground separation, memory distribution pixels and unmount")
print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, full-height chart overlay, memory distribution pixels and unmount")
NSApp.terminate(nil)
}
NSApp.run()
+27
View File
@@ -0,0 +1,27 @@
import Foundation
@main struct StackedSeriesChecks {
static func main() {
let components: [[Double?]] = [[0.2,0,nil,0.4,Double.nan,-0.1], [0.3,0,0.1,0.2,0.1,0.2]]
let bands = StackedSeries.bands(components, count: 6, limit: 1)
precondition(bands[0].lower[0] == 0 && bands[0].upper[0] == 0.2)
precondition(bands[1].lower[0] == 0.2 && bands[1].upper[0] == 0.5)
precondition(bands[1].upper[1] == 0, "Real zero must remain a measured stack")
for index in [2,4,5] {
precondition(bands.allSatisfy { $0.lower[index] == nil && $0.upper[index] == nil },
"Missing or invalid components must not invent partial totals")
}
let memory = StackedSeries.bands([[22,24], [3,4], [1,2]], count: 2, limit: 48)
precondition(memory[2].lower == [25,28] && memory[2].upper == [26,30])
let gpu = StackedSeries.bands([[0,0.7,1], [1,0.3,0]], count: 3, limit: 1)
precondition(gpu.last!.upper == [1,1,1])
precondition(StackedSeries.bands([[0.8],[0.4]], count: 1, limit: 1).allSatisfy { $0.upper == [nil] })
precondition(StackedSeries.bands([[Double.greatestFiniteMagnitude],[Double.greatestFiniteMagnitude]], count: 1).allSatisfy { $0.upper == [nil] })
let dates = (0..<4).map { Date(timeIntervalSinceReferenceDate: Double($0 * 2)) }
let pair = StackedSeries.bands([[0.2,nil,nil,0.3],[0.3,nil,nil,0.2]], count: 4)
let runs = PanelCurveGeometry.runs(dates: dates, values: pair[1].upper, boundaryDates: [dates[2]], lowerValues: pair[1].lower)
precondition(runs.count == 2 && runs[0][0].lower == 0.2 && runs[1][0].lower == 0.3)
precondition(runs.flatMap { $0 }.map(\.date) == [dates[0],dates[3]])
print("PASS: cumulative component boundaries, CPU/memory/GPU sums, zero/missing/invalid/overflow, paired lower boundaries and sampling breaks")
}
}