Skip to content

CI: Fix test_json failure on single-precision (float32)#2257

Merged
bettio merged 1 commit intoatomvm:release-0.7from
petermm:fix-ci-json-float32
Apr 4, 2026
Merged

CI: Fix test_json failure on single-precision (float32)#2257
bettio merged 1 commit intoatomvm:release-0.7from
petermm:fix-ci-json-float32

Conversation

@petermm
Copy link
Copy Markdown
Contributor

@petermm petermm commented Apr 4, 2026

Three JSON test suite cases (y_number, y_number_real_exponent, y_number_real_fraction_exponent) contain float values that exceed the IEEE 754 float32 range (~3.4e38), e.g. 1.23e67, 1.23e47, 1.23456e80.

On AVM_USE_SINGLE_PRECISION builds, binary_to_float/1 calls strtof() which returns inf for these values, failing the isfinite() check and raising badarg.

Skip these three test cases on single-precision builds by checking erlang:system_info(avm_floatsize) at runtime, following the existing pattern used in floatext.erl and other float-sensitive tests.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

Copy link
Copy Markdown
Collaborator

@bettio bettio left a comment

Choose a reason for hiding this comment

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

Can you squash this?

Three JSON test suite cases (y_number, y_number_real_exponent,
y_number_real_fraction_exponent) contain float values that exceed the
IEEE 754 float32 range (~3.4e38), e.g. 1.23e67, 1.23e47, 1.23456e80.

On AVM_USE_SINGLE_PRECISION builds, binary_to_float/1 calls strtof()
which returns inf for these values, failing the isfinite() check and
raising badarg.

Skip these three test cases on single-precision builds by checking
erlang:system_info(avm_floatsize) at runtime, following the existing
pattern used in floatext.erl and other float-sensitive tests.

And:

Fix test_json encode test for single-precision float32

On float32 builds, 3.14 is stored as 3.1400001 (nearest IEEE 754
single-precision representation), so float_to_binary produces
<<"3.1400001">> rather than <<"3.14">>. Use is_single_precision()
to expect the correct output for each precision.

Signed-off-by: Peter M <petermm@gmail.com>
@petermm petermm force-pushed the fix-ci-json-float32 branch from bbf60d7 to 8e22ba5 Compare April 4, 2026 14:15
@petermm petermm changed the title Fix test_json failure on single-precision (float32) CI: Fix test_json failure on single-precision (float32) Apr 4, 2026
@bettio bettio merged commit ffae7cc into atomvm:release-0.7 Apr 4, 2026
119 of 122 checks passed
@petermm petermm deleted the fix-ci-json-float32 branch April 4, 2026 21:39
bettio added a commit that referenced this pull request Apr 4, 2026
Merge fixes, features, and optimizations from release-0.7, including:
- Add json module for estdlib and exavmlib (#2247)
- Add timer:send_after/2,3 and apply_after/4 (#2228)
- Add erlang:display_string/1,2 (#2251)
- Add trim and list patterns to binary:split/2,3 (#2253)
- Implement code:get_object_code/1 (#1864)
- Add SPI support to RP2 platform (#2120)
- JIT: add ARM32 backend (#2248)
- JIT: add Thumb-2 variant for ARMv6-M backend (#2250)
- Fix erlang:raise/3 assert with built stacktrace (#2252)
- Fix test_json failure on single-precision float32 (#2257)
- ESP32: Increase Erlang boot.avm partition to 512KB (#2254)
- CI: Bump to OTP 28 and rebar3 3.25.1 (#2255)
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