diff --git a/crates/wasm_interp/src/tests/test_mem.rs b/crates/wasm_interp/src/tests/test_mem.rs index 09f54d8e54..9d24e0df0d 100644 --- a/crates/wasm_interp/src/tests/test_mem.rs +++ b/crates/wasm_interp/src/tests/test_mem.rs @@ -72,13 +72,14 @@ fn test_memory_fill() { state.value_store.push(Value::I32(SIZE)); // before the instruction, the memory is all zeros - let slice = &state.memory[destination as usize..][..SIZE as usize]; - assert_eq!(slice, &[0; SIZE as usize]); + let memory_before = &state.memory[destination as usize..][..SIZE as usize]; + assert_eq!(memory_before, &[0; SIZE as usize]); state.execute_next_instruction(&module).unwrap(); - let slice = &state.memory[destination as usize..][..SIZE as usize]; - assert_eq!(slice, &[byte_value as u8; SIZE as usize]) + // after the fill, the same memory range is now all 0xAA bytes + let memory_after = &state.memory[destination as usize..][..SIZE as usize]; + assert_eq!(memory_after, &[byte_value as u8; SIZE as usize]) } #[test] @@ -103,16 +104,19 @@ fn test_memory_copy() { state.value_store.push(Value::I32(source)); state.value_store.push(Value::I32(SIZE)); - // before the instruction, the memory is all zeros - let slice = &mut state.memory[source as usize..][..SIZE as usize]; - assert_eq!(slice, &[0; SIZE as usize]); + // fill the source slice with 0xAA bytes + let source_slice = &mut state.memory[source as usize..][..SIZE as usize]; + source_slice.fill(0xAA); - slice.fill(0xAA); + // before the copy, the destination slice is all 0x00 bytes + let dest_slice = &state.memory[destination as usize..][..SIZE as usize]; + assert_eq!(dest_slice, &[0x00; SIZE as usize]); state.execute_next_instruction(&module).unwrap(); - let slice = &state.memory[destination as usize..][..SIZE as usize]; - assert_eq!(slice, &[0xAA; SIZE as usize]) + // after the copy, the destination slice is all 0xAA bytes + let dest_slice = &state.memory[destination as usize..][..SIZE as usize]; + assert_eq!(dest_slice, &[0xAA; SIZE as usize]) } fn test_load(load_op: OpCode, ty: ValueType, data: &[u8], addr: u32, offset: u32) -> Value {