diff --git a/src/instructions/mod.rs b/src/instructions/mod.rs index 7bb7b60..1a42239 100644 --- a/src/instructions/mod.rs +++ b/src/instructions/mod.rs @@ -216,7 +216,9 @@ pub mod macros { if in_stack_len < $fn_arity || aux0_stack_len < $aux0_arity || aux1_stack_len < $aux1_arity { return; } - if $aux0_type == $aux1_type { + // This is crazy jank, not meant for use in actual code :) + // https://doc.rust-lang.org/std/any/fn.type_name.html + if std::any::type_name::<$aux0_type>() == std::any::type_name::<$aux1_type>() { if aux0_stack_len + aux1_stack_len < $aux0_arity + $aux1_arity { return; } @@ -228,7 +230,7 @@ pub mod macros { aux1_inputs.push(state.$aux1_stack[aux1_stack_len - n].clone()); } for n in 1..=$aux0_arity { - aux0_inputs.push(state.$aux0_stack[aux0_stack_len - n].clone()); + aux0_inputs.push(state.$aux0_stack[aux0_stack_len - $aux1_arity - n].clone()); } for n in 1..=$fn_arity { inputs.push(state.$in_stack[in_stack_len - n].clone()); diff --git a/src/instructions/vector.rs b/src/instructions/vector.rs index d808a65..860e54f 100644 --- a/src/instructions/vector.rs +++ b/src/instructions/vector.rs @@ -804,7 +804,7 @@ where { let mut temp_vec = vals[0].clone(); let idx = bounded_idx(aux1[0], temp_vec.len()); - temp_vec.insert(idx, aux0[idx].clone()); + temp_vec.insert(idx, aux0[0].clone()); Some(temp_vec) } make_instruction_aux2!( @@ -1323,11 +1323,14 @@ mod tests { } #[test] - fn set_n_test() { + fn set_nth_test() { let mut test_state = EMPTY_STATE; test_state.vector_int = vec![vec![0, 1, 2, 3, 4, 5]]; test_state.int = vec![99, 1]; vector_int_set_nth(&mut test_state); + assert_eq!(vec![vec![0, 99, 1, 2, 3, 4, 5]], test_state.vector_int); + + // Write more tests tmo! } } diff --git a/src/main.rs b/src/main.rs index f3a87a1..ab3a002 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use crate::push::state::{EMPTY_STATE, PushState}; use instructions::utils::NumericTrait; use rust_decimal::MathematicalOps; use rust_decimal::prelude::*; @@ -40,7 +41,14 @@ fn main() { //let res = 3 % 2; //println!("res is {res}"); - let mut test_vec = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - test_vec.drain(..15); - println!("{:?}", test_vec); + //let mut test_vec = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + //test_vec.drain(..15); + //println!("{:?}", test_vec); + + //let test_state = EMPTY_STATE; + //println!("{}", test_state.int == test_state.boolean); + println!( + "{}", + std::any::type_name::() == std::any::type_name::() + ); }