replace π, more tests
This commit is contained in:
parent
478ce49d8d
commit
c96bce8b37
1 changed files with 28 additions and 2 deletions
|
@ -437,7 +437,7 @@ impl Compiler {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::compiler::{Compiler, Expression, SAMPLE_RATE, Silence};
|
use crate::compiler::{Compiler, Expression, Note, SAMPLE_RATE, Silence};
|
||||||
|
|
||||||
use super::{CompilerError, Context};
|
use super::{CompilerError, Context};
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn silence() -> Result<(), CompilerError> {
|
fn silence_renders_correct_amount_of_samples() -> Result<(), CompilerError> {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
SAMPLE_RATE as usize,
|
SAMPLE_RATE as usize,
|
||||||
Compiler::from(context_generator())
|
Compiler::from(context_generator())
|
||||||
|
@ -475,4 +475,30 @@ mod tests {
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn silence_renders_zeros() -> Result<(), CompilerError> {
|
||||||
|
assert!(
|
||||||
|
Compiler::from(context_generator())
|
||||||
|
.apply_all(vec![Silence])?
|
||||||
|
.0
|
||||||
|
.result
|
||||||
|
.into_iter()
|
||||||
|
.all(|s| s == 0f64)
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn note_renders_correct_amount_of_samples() -> Result<(), CompilerError> {
|
||||||
|
assert_eq!(
|
||||||
|
SAMPLE_RATE as usize,
|
||||||
|
Compiler::from(context_generator())
|
||||||
|
.apply_all(vec![Note(2)])?
|
||||||
|
.0
|
||||||
|
.result
|
||||||
|
.len()
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue