use rush::push::state::EMPTY_STATE; use rush_macro::run_instruction; fn iadd(x: i128, y: i128) -> Option { Some(x + y) } fn aux_iadd(x: i128, y: i128) -> Option> { Some(vec![x + y, x - y]) } fn two_stacks(x: i128, y: i128, cond: bool) -> Option { if cond { Some(x + y) } else { Some(x - y) } } #[test] fn run_extract_test() { let mut test_state = EMPTY_STATE; test_state.int = vec![1, 2]; run_instruction!(iadd, int, test_state, int, int); assert_eq!(vec![3], test_state.int); test_state.int = vec![1]; run_instruction!(iadd, int, test_state, int, int); assert_eq!(vec![1], test_state.int); // If you're coming from the run_instruction docs, this is // the one. test_state.int = vec![1, 2]; run_instruction!(aux_iadd, int, test_state, int, int;); assert_eq!(vec![3, 1], test_state.int); test_state.int = vec![1, 2]; test_state.boolean = vec![true]; run_instruction!(two_stacks, int, test_state, int, int, boolean); }