1.0.0 release
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// PatternWrapTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@Suite("Pattern.wrap")
|
||||
struct PatternWrapTests {
|
||||
|
||||
@Test func wrapsValuesIntoRange() {
|
||||
let pat: Pattern<Double> = Pattern.wrap(
|
||||
Pattern.sequence([0.0, 5.0, 10.0, 12.0, -3.0], repeats: 1),
|
||||
low: 0.0,
|
||||
high: 10.0
|
||||
)
|
||||
#expect(pat.next() == 0.0)
|
||||
#expect(pat.next() == 5.0)
|
||||
#expect(pat.next() == 0.0) // 10.0 wraps to 0.0 (half-open [0, 10))
|
||||
#expect(pat.next() == 2.0) // 12.0 wraps to 2.0
|
||||
#expect(pat.next() == 7.0) // -3.0 wraps to 7.0
|
||||
}
|
||||
|
||||
@Test func wrapsAcrossNegativeRange() {
|
||||
let pat: Pattern<Double> = Pattern.wrap(
|
||||
Pattern.sequence([-5.0, 0.0, 5.0, 6.0], repeats: 1),
|
||||
low: -5.0,
|
||||
high: 5.0
|
||||
)
|
||||
#expect(pat.next() == -5.0)
|
||||
#expect(pat.next() == 0.0)
|
||||
#expect(pat.next() == -5.0) // 5.0 wraps to -5.0
|
||||
#expect(pat.next() == -4.0) // 6.0 wraps to -4.0
|
||||
}
|
||||
|
||||
@Test func resultAlwaysStrictlyBelowHigh() {
|
||||
// Boundary-floor invariant: no input ever produces output == high.
|
||||
let inputs: [Double] = [
|
||||
-10.0, -7.5, -0.0001, 0.0, 5.0, 9.99999999999, 10.0, 100.0,
|
||||
-1e15, 1e15
|
||||
]
|
||||
let pat: Pattern<Double> = Pattern.wrap(
|
||||
Pattern.sequence(inputs, repeats: 1),
|
||||
low: 0.0,
|
||||
high: 10.0
|
||||
)
|
||||
while let v: Double = pat.next() {
|
||||
#expect(v >= 0.0)
|
||||
#expect(v < 10.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user