vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
use vyre::ir::{AtomicOp, BufferDecl, DataType, Expr, Node, Program};
use vyre_conform::{reference::interp, spec::value::Value};

/// ADVERSARIAL: eval_atomic evaluates value operand before OOB check — vector: a nested
/// atomic inside the value expression executes even when the outer atomic target is empty
/// and the operation will be discarded.
#[test]
fn nested_atomic_in_value_is_not_evaluated_when_outer_oob() {
    let program = Program::new(
        vec![
            BufferDecl::read_write("empty", 0, DataType::U32),
            BufferDecl::read_write("side_effect", 1, DataType::U32),
        ],
        [1, 1, 1],
        vec![Node::store(
            "empty",
            Expr::u32(0),
            Expr::Atomic {
                op: AtomicOp::Add,
                buffer: "empty".to_string(),
                index: Box::new(Expr::u32(0)),
                expected: None,
                value: Box::new(Expr::atomic_add("side_effect", Expr::u32(0), Expr::u32(1))),
            },
        )],
    );

    // The outer atomic on "empty" (0 bytes) is OOB, so it must be a no-op.
    // The nested atomic on "side_effect" must NOT execute.
    let outputs = interp::run(
        &program,
        &[Value::Bytes(vec![]), Value::Bytes(vec![0, 0, 0, 0])],
    )
    .expect("OOB atomic must not evaluate nested side effects");

    assert_eq!(
        outputs,
        vec![Value::Bytes(vec![]), Value::Bytes(vec![0, 0, 0, 0])]
    );
}