prep for 1.2.0 release updates

This commit is contained in:
2026-06-21 11:45:58 -07:00
parent 73191c958f
commit 032b7c39d3
286 changed files with 21116 additions and 121 deletions
@@ -0,0 +1,58 @@
// DemandShuffleTests.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Testing
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
@MainActor
@Suite("DemandShuffle")
struct DemandShuffleTests {
@Test func returnsAllValuesExactlyOncePerCycle() {
let d: DemandShuffle = DemandShuffle(
values: [1.0, 2.0, 3.0, 4.0, 5.0],
repeats: 1,
seed: 42
)
var collected: [Double] = []
while let v: Double = d.nextValue() { collected.append(v) }
#expect(collected.sorted() == [1.0, 2.0, 3.0, 4.0, 5.0])
#expect(d.isExhausted)
}
@Test func samePermutationReplaysOnReset() {
let d: DemandShuffle = DemandShuffle(
values: [1.0, 2.0, 3.0, 4.0],
repeats: -1,
seed: 7
)
let first: [Double] = (0..<4).compactMap { _ in d.nextValue() }
d.reset()
let second: [Double] = (0..<4).compactMap { _ in d.nextValue() }
#expect(first == second)
}
@Test func sameSeedProducesSamePermutation() {
let a: DemandShuffle = DemandShuffle(values: [10.0, 20.0, 30.0, 40.0], repeats: 1, seed: 99)
let b: DemandShuffle = DemandShuffle(values: [10.0, 20.0, 30.0, 40.0], repeats: 1, seed: 99)
for _ in 0..<4 {
#expect(a.nextValue() == b.nextValue())
}
}
@Test func resetClearsExhaustion() {
let d: DemandShuffle = DemandShuffle(
values: [1.0, 2.0, 3.0],
repeats: 1,
seed: 5
)
while d.nextValue() != nil {}
#expect(d.isExhausted)
d.reset()
#expect(!d.isExhausted)
#expect(d.nextValue() != nil)
}
}