1.0.0 release
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
// PatternDropTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@Suite("Pattern.drop")
|
||||
struct PatternDropTests {
|
||||
|
||||
@Test func skipsFirstCountValues() {
|
||||
let pat: Pattern<Int> = Pattern.drop(
|
||||
Pattern.sequence([1, 2, 3, 4, 5], repeats: 1),
|
||||
count: 2
|
||||
)
|
||||
#expect(pat.next() == 3)
|
||||
#expect(pat.next() == 4)
|
||||
#expect(pat.next() == 5)
|
||||
#expect(pat.next() == nil)
|
||||
#expect(pat.isExhausted)
|
||||
}
|
||||
|
||||
@Test func countZeroPassesThroughUnchanged() {
|
||||
let pat: Pattern<Int> = Pattern.drop(
|
||||
Pattern.sequence([7, 8, 9], repeats: 1),
|
||||
count: 0
|
||||
)
|
||||
#expect(pat.next() == 7)
|
||||
#expect(pat.next() == 8)
|
||||
#expect(pat.next() == 9)
|
||||
#expect(pat.next() == nil)
|
||||
}
|
||||
|
||||
@Test func countExceedsUpstreamExhaustsImmediately() {
|
||||
let pat: Pattern<Int> = Pattern.drop(
|
||||
Pattern.sequence([1, 2, 3], repeats: 1),
|
||||
count: 10
|
||||
)
|
||||
#expect(pat.next() == nil)
|
||||
}
|
||||
|
||||
@Test func resetRestoresDropsRemaining() {
|
||||
let pat: Pattern<Int> = Pattern.drop(
|
||||
Pattern.sequence([1, 2, 3, 4], repeats: -1),
|
||||
count: 2
|
||||
)
|
||||
_ = pat.next(); _ = pat.next() // emits 3, 4
|
||||
pat.reset()
|
||||
// After reset: drop 2 again then emit
|
||||
#expect(pat.next() == 3)
|
||||
#expect(pat.next() == 4)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user