Feat: all and noall words
This commit is contained in:
@@ -144,3 +144,96 @@ fn explicit_dur_zero_is_infinite() {
|
||||
let outputs = expect_outputs("880 freq 0 dur .", 1);
|
||||
assert!(outputs[0].contains("dur/0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_before_sounds() {
|
||||
let outputs = expect_outputs(
|
||||
r#"500 lpf 0.5 verb all "kick" s 60 note . "hat" s 70 note ."#,
|
||||
2,
|
||||
);
|
||||
assert!(outputs[0].contains("sound/kick"));
|
||||
assert!(outputs[0].contains("lpf/500"));
|
||||
assert!(outputs[0].contains("verb/0.5"));
|
||||
assert!(outputs[1].contains("sound/hat"));
|
||||
assert!(outputs[1].contains("lpf/500"));
|
||||
assert!(outputs[1].contains("verb/0.5"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_after_sounds() {
|
||||
let outputs = expect_outputs(
|
||||
r#""kick" s 60 note . "hat" s 70 note . 500 lpf 0.5 verb all"#,
|
||||
2,
|
||||
);
|
||||
assert!(outputs[0].contains("sound/kick"));
|
||||
assert!(outputs[0].contains("lpf/500"));
|
||||
assert!(outputs[0].contains("verb/0.5"));
|
||||
assert!(outputs[1].contains("sound/hat"));
|
||||
assert!(outputs[1].contains("lpf/500"));
|
||||
assert!(outputs[1].contains("verb/0.5"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn noall_clears_global_params() {
|
||||
let outputs = expect_outputs(
|
||||
r#"500 lpf all "kick" s 60 note . noall "hat" s 70 note ."#,
|
||||
2,
|
||||
);
|
||||
assert!(outputs[0].contains("lpf/500"));
|
||||
assert!(!outputs[1].contains("lpf/500"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_with_tempo_scaled_params() {
|
||||
// attack is tempo-scaled: 0.01 * step_duration(0.125) = 0.00125
|
||||
let outputs = expect_outputs(
|
||||
r#"0.01 attack all "kick" s 60 note ."#,
|
||||
1,
|
||||
);
|
||||
assert!(outputs[0].contains("attack/0.00125"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_per_sound_override() {
|
||||
let outputs = expect_outputs(
|
||||
r#"500 lpf all "kick" s 2000 lpf . "hat" s ."#,
|
||||
2,
|
||||
);
|
||||
// kick has both global lpf=500 and per-sound lpf=2000; per-sound wins (comes last)
|
||||
assert!(outputs[0].contains("lpf/2000"));
|
||||
// hat only has global lpf=500
|
||||
assert!(outputs[1].contains("lpf/500"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_persists_across_evaluations() {
|
||||
let f = forth();
|
||||
let ctx = default_ctx();
|
||||
f.evaluate(r#"500 lpf 0.5 verb all"#, &ctx).unwrap();
|
||||
let outputs = f.evaluate(r#""kick" s 60 note ."#, &ctx).unwrap();
|
||||
assert_eq!(outputs.len(), 1);
|
||||
assert!(outputs[0].contains("lpf/500"), "global lpf missing: {}", outputs[0]);
|
||||
assert!(outputs[0].contains("verb/0.5"), "global verb missing: {}", outputs[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn noall_clears_across_evaluations() {
|
||||
let f = forth();
|
||||
let ctx = default_ctx();
|
||||
f.evaluate(r#"500 lpf all"#, &ctx).unwrap();
|
||||
f.evaluate(r#"noall"#, &ctx).unwrap();
|
||||
let outputs = f.evaluate(r#""kick" s 60 note ."#, &ctx).unwrap();
|
||||
assert_eq!(outputs.len(), 1);
|
||||
assert!(!outputs[0].contains("lpf"), "lpf should be cleared: {}", outputs[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_replaces_previous_global() {
|
||||
let f = forth();
|
||||
let ctx = default_ctx();
|
||||
f.evaluate(r#"500 lpf 0.5 verb all"#, &ctx).unwrap();
|
||||
f.evaluate(r#"2000 lpf all"#, &ctx).unwrap();
|
||||
let outputs = f.evaluate(r#""kick" s ."#, &ctx).unwrap();
|
||||
assert_eq!(outputs.len(), 1);
|
||||
assert!(outputs[0].contains("lpf/2000"), "latest lpf should be 2000: {}", outputs[0]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user