fixes for Swift 6 and threading concerns
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user