Fixed some tests

This commit is contained in:
Weird Constructor 2022-08-18 20:23:56 +02:00
parent d2a10dd4cb
commit 8733656b48
6 changed files with 20 additions and 29 deletions

View file

@ -105,7 +105,7 @@ node_conf.set_prog_node_exec_connection(
node_conf.upload_prog(prog, true); node_conf.upload_prog(prog, true);
let (out_l, out_r) = node_exec.test_run(0.1, false); let (out_l, out_r) = node_exec.test_run(0.1, false, &[]);
``` ```
### Hexagonal Matrix API ### Hexagonal Matrix API
@ -139,7 +139,7 @@ matrix.sync().unwrap();
let gain_p = amp.inp_param("gain").unwrap(); let gain_p = amp.inp_param("gain").unwrap();
matrix.set_param(gain_p, SAtom::param(0.25)); matrix.set_param(gain_p, SAtom::param(0.25));
let (out_l, out_r) = node_exec.test_run(0.11, true); let (out_l, out_r) = node_exec.test_run(0.11, true, &[]);
// out_l and out_r contain two channels of audio // out_l and out_r contain two channels of audio
// samples now. // samples now.
``` ```
@ -163,7 +163,7 @@ chain.node_out("sin", "sig")
.place(&mut matrix, 0, 0); .place(&mut matrix, 0, 0);
matrix.sync().unwrap(); matrix.sync().unwrap();
let (out_l, out_r) = node_exec.test_run(0.11, true); let (out_l, out_r) = node_exec.test_run(0.11, true, &[]);
// out_l and out_r contain two channels of audio // out_l and out_r contain two channels of audio
// samples now. // samples now.
``` ```

View file

@ -526,7 +526,7 @@ mod tests {
assert_eq!( assert_eq!(
s, s,
"{\"VERSION\":2,\"atoms\":[],\"cells\":[],\"params\":[],\"patterns\":[],\"props\":[]}" "{\"VERSION\":2,\"atoms\":[],\"block_funs\":[],\"cells\":[],\"params\":[],\"patterns\":[],\"props\":[]}"
); );
assert!(MatrixRepr::deserialize(&s).is_ok()); assert!(MatrixRepr::deserialize(&s).is_ok());
} }
@ -556,7 +556,7 @@ mod tests {
let s = mr.serialize(); let s = mr.serialize();
assert_eq!(s, assert_eq!(s,
"{\"VERSION\":2,\"atoms\":[[\"out\",0,\"mono\",[\"i\",0]]],\"cells\":[[\"sin\",2,0,0,[-1,-1,-1],[-1,\"sig\",-1]],[\"out\",0,1,0,[-1,\"ch1\",-1],[-1,-1,-1]]],\"params\":[[\"out\",0,\"ch1\",0.0],[\"out\",0,\"ch2\",0.0],[\"sin\",0,\"det\",0.0],[\"sin\",1,\"det\",0.0],[\"sin\",2,\"det\",0.0],[\"sin\",0,\"freq\",440.0],[\"sin\",1,\"freq\",440.0],[\"sin\",2,\"freq\",220.0],[\"out\",0,\"gain\",1.0]],\"patterns\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],\"props\":[]}"); "{\"VERSION\":2,\"atoms\":[[\"out\",0,\"mono\",[\"i\",0]]],\"block_funs\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],\"cells\":[[\"sin\",2,0,0,[-1,-1,-1],[-1,\"sig\",-1]],[\"out\",0,1,0,[-1,\"ch1\",-1],[-1,-1,-1]]],\"params\":[[\"out\",0,\"ch1\",0.0],[\"out\",0,\"ch2\",0.0],[\"sin\",0,\"det\",0.0],[\"sin\",1,\"det\",0.0],[\"sin\",2,\"det\",0.0],[\"sin\",0,\"freq\",440.0],[\"sin\",1,\"freq\",440.0],[\"sin\",2,\"freq\",220.0],[\"out\",0,\"gain\",1.0]],\"patterns\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],\"props\":[]}");
let mut mr2 = MatrixRepr::deserialize(&s).unwrap(); let mut mr2 = MatrixRepr::deserialize(&s).unwrap();
let s2 = mr2.serialize(); let s2 = mr2.serialize();
@ -875,17 +875,6 @@ mod tests {
let new_format = mr.serialize().to_string(); let new_format = mr.serialize().to_string();
assert_eq!(new_format, assert_eq!(new_format,
"{\"VERSION\":1,\"atoms\":[[\"out\",0,\"mono\",[\"i\",0]]],\"cells\":[[\"sin\",2,0,\ "{\"VERSION\":1,\"atoms\":[[\"out\",0,\"mono\",[\"i\",0]]],\"block_funs\":[],\"cells\":[[\"sin\",2,0,0,[-1,-1,-1],[-1,\"sig\",-1]],[\"out\",0,1,0,[-1,\"ch1\",-1],[-1,-1,-1]]],\"params\":[[\"out\",0,\"ch1\",0.0],[\"out\",0,\"ch2\",0.0],[\"sin\",0,\"det\",0.0],[\"sin\",1,\"det\",0.0],[\"sin\",2,\"det\",0.0],[\"sin\",0,\"freq\",0.0],[\"sin\",1,\"freq\",0.0],[\"sin\",2,\"freq\",-0.10000000149011612],[\"out\",0,\"gain\",0.5]],\"patterns\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],\"props\":[]}");
0,[-1,-1,-1],[-1,\"sig\",-1]],[\"out\",0,1,0,[-1,\"ch1\",-1],[-1,-1,-1]]],\"params\":[[\"o\
ut\",0,\"ch1\",0.0],[\"out\",0,\"ch2\",0.0],[\"sin\",0,\"det\",0.0],[\"sin\",1,\"det\",0.0],\
[\"sin\",2,\"det\",0.0],[\"sin\",0,\"freq\",0.0],[\"sin\",1,\"freq\",0.0],[\"sin\",2,\"freq\
\",-0.10000000149011612],[\"out\",0,\"gain\",0.5]],\"patterns\":[null,null,null,null,null,nul\
l,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,\
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,nu\
ll,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null\
,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,n\
ull,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,nul\
l,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,\
null,null,null,null,null,null,null,null,null,null,null,null],\"props\":[]}");
} }
} }

View file

@ -617,12 +617,12 @@ impl NodeConfigurator {
/// ///
/// node_conf.upload_prog(prog, true); /// node_conf.upload_prog(prog, true);
/// ///
/// node_exec.test_run(0.1, false); /// node_exec.test_run(0.1, false, &[]);
/// assert!((node_conf.led_value_for(&NodeId::Sin(0)) - (-0.062522)).abs() < 0.001); /// assert!((node_conf.led_value_for(&NodeId::Sin(0)) - (-0.062522)).abs() < 0.001);
/// assert!((node_conf.led_value_for(&NodeId::Amp(0)) - (-0.062522)).abs() < 0.001); /// assert!((node_conf.led_value_for(&NodeId::Amp(0)) - (-0.062522)).abs() < 0.001);
/// ///
/// for _ in 0..10 { /// for _ in 0..10 {
/// node_exec.test_run(0.1, false); /// node_exec.test_run(0.1, false, &[]);
/// node_conf.update_filters(); /// node_conf.update_filters();
/// node_conf.filtered_led_for(&NodeId::Sin(0)); /// node_conf.filtered_led_for(&NodeId::Sin(0));
/// node_conf.filtered_led_for(&NodeId::Amp(0)); /// node_conf.filtered_led_for(&NodeId::Amp(0));

View file

@ -1819,7 +1819,7 @@ mod test {
fn check_blockfun_serialize_empty() { fn check_blockfun_serialize_empty() {
let dsp_lib = synfx_dsp_jit::get_standard_library(); let dsp_lib = synfx_dsp_jit::get_standard_library();
let lang = crate::wblockdsp::setup_hxdsp_block_language(dsp_lib); let lang = crate::wblockdsp::setup_hxdsp_block_language(dsp_lib);
let mut bf = BlockFun::new(lang.clone()); let bf = BlockFun::new(lang.clone());
let sn = bf.save_snapshot(); let sn = bf.save_snapshot();
let serialized = sn.serialize().to_string(); let serialized = sn.serialize().to_string();
@ -1828,7 +1828,7 @@ mod test {
let v: Value = serde_json::from_str(&serialized).unwrap(); let v: Value = serde_json::from_str(&serialized).unwrap();
let sn = BlockFunSnapshot::deserialize(&v).expect("No deserialization error"); let sn = BlockFunSnapshot::deserialize(&v).expect("No deserialization error");
let mut bf2 = BlockFun::new(lang); let mut bf2 = BlockFun::new(lang);
let bf2 = bf2.load_snapshot(&sn); bf2.load_snapshot(&sn);
} }
#[test] #[test]

View file

@ -56,13 +56,15 @@ fn check_node_code_state() {
let block_fun = matrix.get_block_function(0).expect("block fun exists"); let block_fun = matrix.get_block_function(0).expect("block fun exists");
{ {
let mut block_fun = block_fun.lock().expect("matrix lock"); let mut block_fun = block_fun.lock().expect("matrix lock");
put_v(&mut block_fun, 0, 0, 2, "value", "220.0"); put_v(&mut block_fun, 0, 0, 3, "value", "220.0");
put_n(&mut block_fun, 0, 1, 2, "phase"); put_n(&mut block_fun, 0, 1, 2, "phase");
put_v(&mut block_fun, 0, 1, 3, "value", "2.0"); block_fun.shift_port(0, 1, 2, 0, false); // move reset up
put_n(&mut block_fun, 0, 2, 2, "*"); block_fun.shift_port(0, 1, 2, 0, true); // move output down
put_n(&mut block_fun, 0, 3, 1, "-"); put_v(&mut block_fun, 0, 1, 4, "value", "2.0");
put_v(&mut block_fun, 0, 2, 1, "value", "1.0"); put_n(&mut block_fun, 0, 2, 3, "*");
put_v(&mut block_fun, 0, 4, 1, "set", "&sig1"); put_n(&mut block_fun, 0, 3, 2, "-");
put_v(&mut block_fun, 0, 2, 2, "value", "1.0");
put_v(&mut block_fun, 0, 4, 2, "set", "&sig1");
} }
matrix.check_block_function(0).expect("no compile error"); matrix.check_block_function(0).expect("no compile error");

View file

@ -65,7 +65,7 @@ fn check_node_midicc_test_slew() {
// Test run for 5ms with 3 Note On events at sample positions // Test run for 5ms with 3 Note On events at sample positions
// 5, 10 and 130 in this block of samples: // 5, 10 and 130 in this block of samples:
let (ch1, ch2) = node_exec.test_run( let (ch1, _ch2) = node_exec.test_run(
0.005, 0.005,
false, false,
&[ &[
@ -117,7 +117,7 @@ fn check_node_midicc_test_slew2() {
// Test run for 5ms with 3 Note On events at sample positions // Test run for 5ms with 3 Note On events at sample positions
// 5, 10 and 130 in this block of samples: // 5, 10 and 130 in this block of samples:
let (ch1, ch2) = node_exec.test_run( let (ch1, _ch2) = node_exec.test_run(
0.005, 0.005,
false, false,
&[ &[