Skip to content

test(vm): add comprehensive unit tests for bytecode argument encoding and decoding (#4240)#4735

Open
ParthMozarkar wants to merge 2 commits intoboa-dev:mainfrom
ParthMozarkar:fix-4240
Open

test(vm): add comprehensive unit tests for bytecode argument encoding and decoding (#4240)#4735
ParthMozarkar wants to merge 2 commits intoboa-dev:mainfrom
ParthMozarkar:fix-4240

Conversation

@ParthMozarkar
Copy link

Summary

This PR adds comprehensive unit tests for bytecode argument encoding and decoding in:

core/engine/src/vm/opcode/args.rs

as requested in issue #4240.

What’s Included

  • ✅ Tests verifying correct encoding and decoding of opcode arguments.
  • ✅ Round-trip validation (encode → decode → assert equality).
  • ✅ Boundary condition tests for edge-case values.
  • ✅ Out-of-bounds read tests to ensure panics occur as expected.
  • ✅ Negative test cases validating safety guarantees.

Motivation

Bytecode argument handling is a critical component of the VM execution pipeline.
These tests strengthen confidence in argument parsing correctness and protect against silent corruption or unsafe memory access.

By covering both valid and invalid cases, this improves robustness and makes future refactors safer.

Verification

  • cargo test passes successfully.
  • No Clippy warnings introduced.
  • Formatting verified with cargo fmt.

Closes #4240

@ParthMozarkar ParthMozarkar requested a review from a team as a code owner February 26, 2026 07:49
@github-actions
Copy link

github-actions bot commented Feb 26, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,862 52,862 0
Passed 49,505 49,504 -1
Ignored 2,261 2,262 +1
Failed 1,096 1,096 0
Panics 0 0 0
Conformance 93.65% 93.65% -0.00%

@Sharktheone
Copy link

Sharktheone commented Feb 26, 2026

I think you should base this off main and not off your own branch with console.table implemented

@ParthMozarkar
Copy link
Author

Thanks for pointing that out you're right.

I’ve rebased the branch on top of main and force pushed the updated changes so the PR now only contains the unit test additions for #4240.

Please let me know if anything else needs adjustment. 🙌

@jedel1043 jedel1043 added test Issues and PRs related to the tests. vm Issues and PRs related to the Boa Virtual Machine. waiting-on-review Waiting on reviews from the maintainers labels Feb 27, 2026
The test test_complex_tuple_decode_out_of_bounds provided an array of size 3 for a type that requires 3 bytes ((u8, i8) where the first is the format u8). Modifying the test array to [0, 1] reduces length to 2, correctly testing the bounds error.

Also explicitly used the unified read::<u8> to bounds check reading the format byte across decode implementations.
@ParthMozarkar
Copy link
Author

@jedel1043
everything is perfect i feel like so if you could please review it for merging...it would be great !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Issues and PRs related to the tests. vm Issues and PRs related to the Boa Virtual Machine. waiting-on-review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for bytecode arguments reading

3 participants