test-utils: `build_test!()` and `Test::expect_stack()` take opposite stack orders
- 主要语言
- Rust
- 星标
- 772
- 派生
- 352
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 93
描述
The `build_test!()` family of macros take an input operand stack: https://github.com/0xMiden/miden-vm/blob/469c13972fb96036e89d326367b4cbe43a9f072b/crates/utils/testing/src/test_builders.rs#L112-L137
and `Test::expect_stack()` takes an expected output operand stack: https://github.com/0xMiden/miden-vm/blob/469c13972fb96036e89d326367b4cbe43a9f072b/crates/utils/testing/src/lib.rs#L225-L232
However these two parameters are in *opposite order* from each other. That is, the following test succeeds:
```rust
#[test]
fn test_stack_order() {
build_test!("begin nop end", &[0, 1, 2, 3]).expect_stack(&[3, 2, 1, 0]);
}
```
Technically the `build_test!()` family simply pass the input stack slice as `Test { stack_inputs }`. `stack_inputs` is of type `StackInputs`, which is documented to be in "stack-order": https://github.com/0xMiden/miden-vm/blob/469c13972fb96036e89d326367b4cbe43a9f072b/core/src/stack/inputs.rs#L12-L17
And *internally* `expect_stack()` uses `StackOutputs`, which is documented to be in the opposite order (though this is not called out so explicitly): https://github.com/0xMiden/miden-vm/blob/469c13972fb96036e89d326367b4cbe43a9f072b/core/src/stack/outputs.rs#L12-L20
So upon investigation, this behavior is consistent, but it *is* very confusing; none of the docs for the testing functions, macros, or structs mention this. In fact, `expect_stack()` claims that its parameter is in stack order:
> Builds a final stack from the provided **stack-ordered** array and asserts that executing the test will result in the expected final stack state.
\[Emphasis mine\]
Was `expect_stack()` intended to take stack-order, or is this purely a docs issue?
贡献指南
评估
这个 Issue 还没有评估数据。