fixes for Swift 6 and threading concerns

This commit is contained in:
2026-06-02 12:09:44 -07:00
parent 2fa4bfd45e
commit 6d3a0930a1
327 changed files with 1596 additions and 199 deletions
@@ -11,6 +11,7 @@ import LyrebirdSynth
#if os(macOS)
@MainActor
@Suite("LiveSession diagnostics")
struct LiveSessionDiagnosticsTests {
@@ -11,6 +11,7 @@ import LyrebirdSynth
#if os(macOS)
@MainActor
@Suite("LiveSession")
struct LiveSessionTests {
@@ -73,6 +74,27 @@ struct LiveSessionTests {
#expect(session.lastSnippetMessage == "async hello")
}
/// Phase 203 runtime guard: a snippet driven through `compileAndRunAsync` that calls
/// `context.play(_:)` actually adds and tracks a synth. `context.play` → `engine.add` is
/// `@MainActor` (Phase 201); `compileAndRunAsync` resumes the snippet entry on the main
/// actor (not the nonisolated executor it suspends on), so this exercises that hop.
@Test
func asyncCompileAndRunPlaysAndTracksSynth() async throws {
let engine: SynthesisEngine = makeEngine()
let session: LiveSession = LiveSession(engine: engine)
#expect(session.trackedSynthCount == 0)
let body: String = """
final class SineSynth: SynthesizerBase {
override func build() {
output(bus: 0, source: OscSin.Audio(freq: 440, mul: 0.1))
}
}
_ = context.play(SineSynth())
"""
_ = try await session.compileAndRunAsync(body)
#expect(session.trackedSynthCount == 1)
}
@Test
func asyncCompileFailureSurfacesDiagnosticsThroughSnippetCompileFailed() async {
let engine: SynthesisEngine = makeEngine()