mirror of
https://github.com/phranck/TUIkit.git
synced 2026-06-20 09:54:37 +00:00
Add @MainActor to View, ViewModifier, Renderable, App, Scene protocols and all builders (ViewBuilder, SceneBuilder, ChildInfoProvider). Update renderToBuffer(), makeChildInfo(), resolveChildInfos() for main-actor isolation. Mark generic Equatable conformances with @preconcurrency. Update all 45 test suites with @MainActor annotation.
50 lines
1.1 KiB
Swift
50 lines
1.1 KiB
Swift
// 🖥️ TUIKit — Terminal UI Kit for Swift
|
||
// PulseTimerTests.swift
|
||
//
|
||
// Created by LAYERED.work
|
||
// License: MIT
|
||
|
||
import Testing
|
||
|
||
@testable import TUIkit
|
||
|
||
@MainActor
|
||
@Suite("PulseTimer Tests")
|
||
struct PulseTimerTests {
|
||
|
||
@Test("Initial phase is zero")
|
||
func initialPhaseZero() {
|
||
let appState = AppState()
|
||
let timer = PulseTimer(renderNotifier: appState)
|
||
#expect(timer.phase == 0)
|
||
}
|
||
|
||
@Test("Phase stays within 0-1 range")
|
||
func phaseRange() {
|
||
let appState = AppState()
|
||
let timer = PulseTimer(renderNotifier: appState)
|
||
|
||
// Phase is computed from sin(), which for our mapping gives 0–1
|
||
let phase = timer.phase
|
||
#expect(phase >= 0 && phase <= 1)
|
||
}
|
||
|
||
@Test("Start and stop are balanced")
|
||
func startStopBalanced() {
|
||
let appState = AppState()
|
||
let timer = PulseTimer(renderNotifier: appState)
|
||
|
||
// Should not crash when stopped without starting
|
||
timer.stop()
|
||
|
||
// Start then stop
|
||
timer.start()
|
||
timer.stop()
|
||
|
||
// Double start should be a no-op
|
||
timer.start()
|
||
timer.start()
|
||
timer.stop()
|
||
}
|
||
}
|