fixed aux2/set_nth
This commit is contained in:
parent
abe835017b
commit
a17bdbbf88
@ -216,7 +216,9 @@ pub mod macros {
|
|||||||
if in_stack_len < $fn_arity || aux0_stack_len < $aux0_arity || aux1_stack_len < $aux1_arity {
|
if in_stack_len < $fn_arity || aux0_stack_len < $aux0_arity || aux1_stack_len < $aux1_arity {
|
||||||
return;
|
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 {
|
if aux0_stack_len + aux1_stack_len < $aux0_arity + $aux1_arity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -228,7 +230,7 @@ pub mod macros {
|
|||||||
aux1_inputs.push(state.$aux1_stack[aux1_stack_len - n].clone());
|
aux1_inputs.push(state.$aux1_stack[aux1_stack_len - n].clone());
|
||||||
}
|
}
|
||||||
for n in 1..=$aux0_arity {
|
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 {
|
for n in 1..=$fn_arity {
|
||||||
inputs.push(state.$in_stack[in_stack_len - n].clone());
|
inputs.push(state.$in_stack[in_stack_len - n].clone());
|
||||||
|
@ -804,7 +804,7 @@ where
|
|||||||
{
|
{
|
||||||
let mut temp_vec = vals[0].clone();
|
let mut temp_vec = vals[0].clone();
|
||||||
let idx = bounded_idx(aux1[0], temp_vec.len());
|
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)
|
Some(temp_vec)
|
||||||
}
|
}
|
||||||
make_instruction_aux2!(
|
make_instruction_aux2!(
|
||||||
@ -1323,11 +1323,14 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_n_test() {
|
fn set_nth_test() {
|
||||||
let mut test_state = EMPTY_STATE;
|
let mut test_state = EMPTY_STATE;
|
||||||
|
|
||||||
test_state.vector_int = vec![vec![0, 1, 2, 3, 4, 5]];
|
test_state.vector_int = vec![vec![0, 1, 2, 3, 4, 5]];
|
||||||
test_state.int = vec![99, 1];
|
test_state.int = vec![99, 1];
|
||||||
vector_int_set_nth(&mut test_state);
|
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!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -1,3 +1,4 @@
|
|||||||
|
use crate::push::state::{EMPTY_STATE, PushState};
|
||||||
use instructions::utils::NumericTrait;
|
use instructions::utils::NumericTrait;
|
||||||
use rust_decimal::MathematicalOps;
|
use rust_decimal::MathematicalOps;
|
||||||
use rust_decimal::prelude::*;
|
use rust_decimal::prelude::*;
|
||||||
@ -40,7 +41,14 @@ fn main() {
|
|||||||
//let res = 3 % 2;
|
//let res = 3 % 2;
|
||||||
//println!("res is {res}");
|
//println!("res is {res}");
|
||||||
|
|
||||||
let mut test_vec = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
//let mut test_vec = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
test_vec.drain(..15);
|
//test_vec.drain(..15);
|
||||||
println!("{:?}", test_vec);
|
//println!("{:?}", test_vec);
|
||||||
|
|
||||||
|
//let test_state = EMPTY_STATE;
|
||||||
|
//println!("{}", test_state.int == test_state.boolean);
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
std::any::type_name::<PushState>() == std::any::type_name::<PushState>()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user