prep for 1.2.0 release updates
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// DemandConcatenateTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandConcatenate")
|
||||
struct DemandConcatenateTests {
|
||||
|
||||
@Test func playsEachInTurn() {
|
||||
let d: DemandConcatenate = DemandConcatenate(demands: [
|
||||
DemandSequence(values: [1.0, 2.0], repeats: 1),
|
||||
DemandSequence(values: [10.0, 20.0, 30.0], repeats: 1),
|
||||
DemandSequence(values: [100.0], repeats: 1)
|
||||
])
|
||||
var collected: [Double] = []
|
||||
while let v: Double = d.nextValue() { collected.append(v) }
|
||||
#expect(collected == [1.0, 2.0, 10.0, 20.0, 30.0, 100.0])
|
||||
#expect(d.isExhausted)
|
||||
}
|
||||
|
||||
@Test func emptyListExhaustsImmediately() {
|
||||
let d: DemandConcatenate = DemandConcatenate(demands: [])
|
||||
#expect(d.nextValue() == nil)
|
||||
#expect(d.isExhausted)
|
||||
}
|
||||
|
||||
@Test func skipsExhaustedSubSources() {
|
||||
let d: DemandConcatenate = DemandConcatenate(demands: [
|
||||
DemandSequence(values: [], repeats: 1),
|
||||
DemandSequence(values: [5.0], repeats: 1),
|
||||
DemandSequence(values: [], repeats: 1),
|
||||
DemandSequence(values: [10.0], repeats: 1)
|
||||
])
|
||||
var collected: [Double] = []
|
||||
while let v: Double = d.nextValue() { collected.append(v) }
|
||||
#expect(collected == [5.0, 10.0])
|
||||
}
|
||||
|
||||
@Test func resetReplaysAll() {
|
||||
let d: DemandConcatenate = DemandConcatenate(demands: [
|
||||
DemandSequence(values: [1.0, 2.0], repeats: 1),
|
||||
DemandSequence(values: [3.0, 4.0], repeats: 1)
|
||||
])
|
||||
var first: [Double] = []
|
||||
while let v: Double = d.nextValue() { first.append(v) }
|
||||
#expect(first == [1.0, 2.0, 3.0, 4.0])
|
||||
d.reset()
|
||||
var second: [Double] = []
|
||||
while let v: Double = d.nextValue() { second.append(v) }
|
||||
#expect(second == first)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user