Skip to content

Add test for integer limits #20353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Add test for integer limits #20353

wants to merge 1 commit into from

Conversation

RReverser
Copy link
Collaborator

While debugging an issue with integers in #20344, I found some cases where conversions currently fail or don't behave as expected in WASM64 mode.

In the end, I decided to add a separate test that solely tests all integer limits and ensures they roundtrip between JS and C++ as expected.

I don't have time to look into fixing uncovered issues, but I thought these (currently failing) tests might be a helpful start on their own.

While debugging an issue with integers in #20344, I found some cases where conversions currently fail or don't behave as expected in WASM64 mode.

In the end, I decided to add a separate test that solely tests all integer limits and ensures they roundtrip between JS and C++ as expected.

I don't have time to look into fixing uncovered issues, but I thought these (currently failing) tests might be a helpful start on their own.
@RReverser
Copy link
Collaborator Author

@brendandahl @sbc100 Any chance one of you could look into this one? I'm not familiar with wasm64 yet and not sure what expectations for those types are, yet running into those issues regularly even on subtle changes to Embind.

#define TEST_NUM_LIMITS(T) ok &= test_num_limits<T>(#T)

int main() {
bool ok = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the actual failure we (I) tend to prefer just using assert(..) everywhere rather than accumulating the failures in some kind of success or ok variable.

It means test will exit on first failure but I've found that that is almost always what I want anyway (since it avoids having to page back through reams of output to find the first failure when debugging).

This also makes the tests simpler since you can basically remove ok from here and everywhere else in this file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means test will exit on first failure but I've found that that is almost always what I want anyway

That's what I almost always want too, but I believe in this case an exception was warranted: there are various failure edge cases and the goal was to uncover all of them in a flat list. Otherwise we wouldn't know what other bugs are there until we fix the first one and the next one is uncovered and so on.

When all those bugs are fixed, we can revert this to simpler version if that's desirable, but for now it was more of a "show all types that are broken" exploration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(worth noting that it still doesn't fully realise that goal because at some point test crashes with JS exception after regular value mismatches, so there are probably more things broken after that line)

@RReverser
Copy link
Collaborator Author

Had a brief look at the exception again and looks like at least the crash comes from wrappers in function applySignatureConversions(wasmExports) {, so not even reaching Embind itself.

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.

2 participants