-
Notifications
You must be signed in to change notification settings - Fork 452
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
Add float conversion tests #81
Conversation
Confirming that Xuxing Huang is a member of the W3C CG. Thanks! |
lgtm |
Picked +/-0, +/- INT_MAX, +/-1 to test Int2Float, 0, 1, +/- MOST-POSITIVE-DOUBLE(SINGLE)-FLOAT, +/- LEAST-POSITIVE-DOUBLE(SINGLE)-FLOAT to test reinterpretFloat2Int, some of the results of reinterpretInt2Float will generate NaN so I didn't add them. All tests have one or more random cases :) |
(assert_eq (invoke "$f32_convert_u_i32" (i32.const 0)) (f32.const 0.0)) | ||
(assert_eq (invoke "$f32_convert_u_i32" (i32.const 2147483647)) (f32.const 2147483647)) | ||
(assert_eq (invoke "$f32_convert_u_i32" (i32.const -2147483648)) (f32.const 2147483648)) | ||
(assert_eq (invoke "$f32_convert_u_i32" (i32.const 305419896)) (f32.const 305419896)) ;; 0x12345678 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wasm parser does recognize hexadecimal constants now, so you can write the constant directly now instead of writing it in decimal and having a comment :-).
This looks good! One thing to watch out for: Constants such as 2147483647, 9223372036854775807, and 1234567890 are not exactly representable as f32 values; the wasm parser is silently rounding them. This is obviously not ideal. Eventually we should implement hexadecimal float literal parsing, and then we'll probably convert most of these tests to use it, but if you want to be tidy in the mean time, it'd be nice to avoid values that need rounding. If you're interested in writing more conversion tests, here are some further ideas :-) :
We'll also eventually need to add -0, NaN, Infinity, and trapping cases, though as you noticed these aren't all convenient to do right now. I have some possible ideas for this in this branch, though there's discussion ongoing about them in #70. |
Add float conversion tests
Revert "Update docs to allow import/export mut globals (WebAssembly#81)" This reverts commit 5d2ad6e. Revert "Support import/export mut globals in interpreter (WebAssembly#80)" This reverts commit 07a6fb2.
Fixed a typo
This patch redefines the `switch` instruction such that it only takes a single immediate type (in addition to the tag). Resolves WebAssembly#76.
No description provided.