Skip to content

Mocking with multiple or no arguments#381

Draft
MaartenS11 wants to merge 10 commits into
mainfrom
feat/mocking-multiple-args
Draft

Mocking with multiple or no arguments#381
MaartenS11 wants to merge 10 commits into
mainfrom
feat/mocking-multiple-args

Conversation

@MaartenS11
Copy link
Copy Markdown
Member

@MaartenS11 MaartenS11 commented Jun 3, 2026

MIO was restricted to mocking primitives that had one argument, this PR aims to expand mocking to work with any number of arguments. This is achieved by hashing (with FNV-1a) the argument list + fidx and using this as the key in the mocking table. Since hashes can of course collide (especially when using a fast non-cryptographic hash like we do here) the table does not store a single element for each hash but a list of buckets (which should normally be extremely short).

@MaartenS11 MaartenS11 force-pushed the feat/mocking-multiple-args branch from 4edfc07 to fed0f75 Compare June 3, 2026 14:24
Base automatically changed from fix/memory-leaks to main June 4, 2026 08:21
This allows variable numbers of arguments to be stored and matched.

TODO:
- Use buckets for collisions!
- Update the overrides state in snapshots
@MaartenS11 MaartenS11 force-pushed the feat/mocking-multiple-args branch from fed0f75 to 5076a38 Compare June 4, 2026 08:25
@MaartenS11 MaartenS11 force-pushed the feat/mocking-multiple-args branch from 6061893 to 76c8650 Compare June 4, 2026 09:01
Previously remove would look up the item again when we already look it up and should know where it is.
@MaartenS11 MaartenS11 force-pushed the feat/mocking-multiple-args branch from 76c8650 to 160d2e0 Compare June 4, 2026 09:02
@MaartenS11 MaartenS11 force-pushed the feat/mocking-multiple-args branch from e198853 to de0a71e Compare June 4, 2026 09:53
@MaartenS11 MaartenS11 force-pushed the feat/mocking-multiple-args branch from de0a71e to a4b840d Compare June 4, 2026 12:14
…tead of implementing it partially myself which made it more complex

Unordered map already has buckets, by then storing my own bucket list in those buckets things just got more complex and slower.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant