1.0.0 release
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// PatternRejectTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@Suite("Pattern.reject")
|
||||
struct PatternRejectTests {
|
||||
|
||||
@Test func keepsValuesFailingPredicate() {
|
||||
let pat: Pattern<Int> = Pattern.reject(
|
||||
Pattern.sequence([1, 2, 3, 4, 5, 6], repeats: 1),
|
||||
where: { $0 % 2 == 0 }
|
||||
)
|
||||
var collected: [Int] = []
|
||||
while let v: Int = pat.next() { collected.append(v) }
|
||||
#expect(collected == [1, 3, 5])
|
||||
}
|
||||
|
||||
@Test func emptyResultWhenPredicateAlwaysTrue() {
|
||||
let pat: Pattern<Int> = Pattern.reject(
|
||||
Pattern.sequence([1, 2, 3], repeats: 1),
|
||||
where: { _ in true }
|
||||
)
|
||||
#expect(pat.next() == nil)
|
||||
#expect(pat.isExhausted)
|
||||
}
|
||||
|
||||
@Test func passThroughWhenPredicateAlwaysFalse() {
|
||||
let pat: Pattern<Int> = Pattern.reject(
|
||||
Pattern.sequence([10, 20, 30], repeats: 1),
|
||||
where: { _ in false }
|
||||
)
|
||||
var collected: [Int] = []
|
||||
while let v: Int = pat.next() { collected.append(v) }
|
||||
#expect(collected == [10, 20, 30])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user