From 8733656b48755a7f55b35261336d9e91b5892509 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Thu, 18 Aug 2022 20:23:56 +0200 Subject: [PATCH] Fixed some tests --- src/lib.rs | 6 +++--- src/matrix_repr.rs | 17 +++-------------- src/nodes/node_conf.rs | 4 ++-- src/wblockdsp/language.rs | 4 ++-- tests/node_code.rs | 14 ++++++++------ tests/node_midicc.rs | 4 ++-- 6 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6f7a420..136dff0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,7 +105,7 @@ node_conf.set_prog_node_exec_connection( 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 @@ -139,7 +139,7 @@ matrix.sync().unwrap(); let gain_p = amp.inp_param("gain").unwrap(); 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 // samples now. ``` @@ -163,7 +163,7 @@ chain.node_out("sin", "sig") .place(&mut matrix, 0, 0); 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 // samples now. ``` diff --git a/src/matrix_repr.rs b/src/matrix_repr.rs index f054aa5..bdc25e4 100644 --- a/src/matrix_repr.rs +++ b/src/matrix_repr.rs @@ -526,7 +526,7 @@ mod tests { assert_eq!( s, - "{\"VERSION\":2,\"atoms\":[],\"cells\":[],\"params\":[],\"patterns\":[],\"props\":[]}" + "{\"VERSION\":2,\"atoms\":[],\"block_funs\":[],\"cells\":[],\"params\":[],\"patterns\":[],\"props\":[]}" ); assert!(MatrixRepr::deserialize(&s).is_ok()); } @@ -556,7 +556,7 @@ mod tests { let s = mr.serialize(); 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 s2 = mr2.serialize(); @@ -875,17 +875,6 @@ mod tests { let new_format = mr.serialize().to_string(); assert_eq!(new_format, - "{\"VERSION\":1,\"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\":[[\"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\":[]}"); + "{\"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\":[]}"); } } diff --git a/src/nodes/node_conf.rs b/src/nodes/node_conf.rs index 37e8b1c..d9ecca4 100644 --- a/src/nodes/node_conf.rs +++ b/src/nodes/node_conf.rs @@ -617,12 +617,12 @@ impl NodeConfigurator { /// /// 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::Amp(0)) - (-0.062522)).abs() < 0.001); /// /// for _ in 0..10 { - /// node_exec.test_run(0.1, false); + /// node_exec.test_run(0.1, false, &[]); /// node_conf.update_filters(); /// node_conf.filtered_led_for(&NodeId::Sin(0)); /// node_conf.filtered_led_for(&NodeId::Amp(0)); diff --git a/src/wblockdsp/language.rs b/src/wblockdsp/language.rs index 17dc369..44e3e11 100644 --- a/src/wblockdsp/language.rs +++ b/src/wblockdsp/language.rs @@ -1819,7 +1819,7 @@ mod test { fn check_blockfun_serialize_empty() { let dsp_lib = synfx_dsp_jit::get_standard_library(); 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 serialized = sn.serialize().to_string(); @@ -1828,7 +1828,7 @@ mod test { let v: Value = serde_json::from_str(&serialized).unwrap(); let sn = BlockFunSnapshot::deserialize(&v).expect("No deserialization error"); let mut bf2 = BlockFun::new(lang); - let bf2 = bf2.load_snapshot(&sn); + bf2.load_snapshot(&sn); } #[test] diff --git a/tests/node_code.rs b/tests/node_code.rs index 45ec533..2318ed7 100644 --- a/tests/node_code.rs +++ b/tests/node_code.rs @@ -56,13 +56,15 @@ fn check_node_code_state() { let block_fun = matrix.get_block_function(0).expect("block fun exists"); { 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_v(&mut block_fun, 0, 1, 3, "value", "2.0"); - put_n(&mut block_fun, 0, 2, 2, "*"); - put_n(&mut block_fun, 0, 3, 1, "-"); - put_v(&mut block_fun, 0, 2, 1, "value", "1.0"); - put_v(&mut block_fun, 0, 4, 1, "set", "&sig1"); + block_fun.shift_port(0, 1, 2, 0, false); // move reset up + block_fun.shift_port(0, 1, 2, 0, true); // move output down + put_v(&mut block_fun, 0, 1, 4, "value", "2.0"); + put_n(&mut block_fun, 0, 2, 3, "*"); + 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"); diff --git a/tests/node_midicc.rs b/tests/node_midicc.rs index 0facf1e..4497dff 100644 --- a/tests/node_midicc.rs +++ b/tests/node_midicc.rs @@ -65,7 +65,7 @@ fn check_node_midicc_test_slew() { // Test run for 5ms with 3 Note On events at sample positions // 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, false, &[ @@ -117,7 +117,7 @@ fn check_node_midicc_test_slew2() { // Test run for 5ms with 3 Note On events at sample positions // 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, false, &[