clarify comments in tests

This commit is contained in:
Folkert 2023-07-10 12:11:54 +02:00
parent f813591042
commit 5bc75b7a03
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -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 {