use rush::push::state::EMPTY_STATE;
use rush_macro::run_instruction;

fn iadd(x: i128, y: i128) -> Option<i128> {
    Some(x + y)
}

fn aux_iadd(x: i128, y: i128) -> Option<Vec<i128>> {
    Some(vec![x + y, 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);
}