Skip to content

Add unit tests for bytecode argument reading (args.rs)#5287

Open
Cypher-CP0 wants to merge 1 commit intoboa-dev:mainfrom
Cypher-CP0:add-tests-bytecode-args-reading
Open

Add unit tests for bytecode argument reading (args.rs)#5287
Cypher-CP0 wants to merge 1 commit intoboa-dev:mainfrom
Cypher-CP0:add-tests-bytecode-args-reading

Conversation

@Cypher-CP0
Copy link
Copy Markdown

Summary

Closes #4240

Adds unit tests for the bytecode argument reading logic in core/engine/src/vm/opcode/args.rs, as requested in the linked issue.

Changes

Added the following test coverage inside the existing #[cfg(test)] mod tests block in args.rs:

Direct read function tests

  • read_u8_direct — basic u8 read
  • read_u16_little_endian — verifies correct little-endian byte ordering for u16
  • read_u32_little_endian — verifies correct little-endian byte ordering for u32
  • read_at_non_zero_offset — verifies reading from a non-zero offset advances pos correctly

Signed negative value tests

  • read_i8_negative — reads -1 as i8
  • read_i16_negative — reads -1 as i16 in little-endian
  • read_i32_negative — reads i32::MIN from raw bytes

Operand edge cases

  • register_operand_large_valueRegisterOperand with u32::MAX
  • index_operand_mid_valueIndexOperand with a mid-range value
  • address_max_valueAddress with u32::MAX
  • decode_at_non_zero_offset — decodes the second of two back-to-back encoded values

Primitive edge cases

  • test_i8_max, test_i16_min_max, test_i32_max, test_u8_mid_value

Float special values

  • test_f32_special_values — NaN, +inf, -inf for f32
  • test_f64_special_values — NaN, +inf, -inf for f64

Additional tuple combinations

  • test_triple_tuple_round_trip — 3-element tuples
  • test_five_tuple_round_trip — 5-element tuples

Additional panic/truncation tests

  • decode_u16_truncated_panics — 1 byte buffer for u16
  • decode_u64_truncated_panics — 4 byte buffer for u64
  • decode_at_offset_past_end_panics — offset + size exceeds buffer length

Additional ThinVec tests

  • test_thin_vec_single_element — single element vec
  • test_thin_vec_index_operand — ThinVec of IndexOperand with min/max values

@Cypher-CP0 Cypher-CP0 requested a review from a team as a code owner March 30, 2026 19:47
@github-actions github-actions bot added Waiting On Review Waiting on reviews from the maintainers C-VM Issues and PRs related to the Boa Virtual Machine. and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 30, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-VM Issues and PRs related to the Boa Virtual Machine.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for bytecode arguments reading

1 participant