Files
josh 62b2f5dbec v1.5.0 release: LyrebirdRandom + Live Scratch editor
LyrebirdRandom scalar distribution sampling (seedable value type + shared
Random) with DistributionKind.sample dispatcher. Live Scratch editor: rename to
LyrebirdScratch, App Support artifact staging, Format Code (⌥⌘F), Render to File
(⌥⌘R offline CAF), line-number gutter, manual completion, Foundation in snippets,
scroll-jump fix, scheduling/NRT docs.
2026-07-22 07:53:12 -07:00

49 lines
1.5 KiB
Swift

// ScratchModelFormatTests.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
#if os(macOS)
import Testing
import LyrebirdSynth
@testable import LyrebirdLiveCompile
@testable import LyrebirdLiveCompileUI
@Suite("LyrebirdScratchModel formatting")
@MainActor
struct ScratchModelFormatTests {
private func makeModel(text: String) -> LyrebirdScratchModel {
let engine: SynthesisEngine = SynthesisEngine(
blockSize: 64,
controlBlockSize: 16,
sampleRate: 48_000,
numOutputChannels: 2,
numInputChannels: 0,
numAudioBuses: 16,
numControlBuses: 16,
eventQueueCapacity: lyrebirdDefaultEventQueueCapacity,
driver: OfflineDriver()
)
return LyrebirdScratchModel(session: LiveSession(engine: engine, attachScope: false), initialText: text)
}
@Test func formatRewritesMessyBufferAndLogs() async {
guard SwiftFormatter.isAvailable else { return } // no toolchain formatter — skip
let model: LyrebirdScratchModel = makeModel(text: "let x=1\n")
await model.formatBuffer()
#expect(model.text.contains("let x = 1"))
#expect(model.consoleEntries.contains { $0.kind == .info })
}
@Test func formatBlankBufferIsNoOp() async {
let model: LyrebirdScratchModel = makeModel(text: " \n")
let before: String = model.text
await model.formatBuffer()
#expect(model.text == before)
}
}
#endif