fix emscripten

This commit is contained in:
Joao Paulo Magalhaes
2024-04-18 22:21:36 +01:00
parent 1a6262029e
commit f411f9ccb9
3 changed files with 21 additions and 19 deletions

View File

@@ -14,6 +14,22 @@ JavaScript
A JavaScript+WebAssembly port is available, compiled through
`emscripten <https://emscripten.org/>`__.
Here's a quick example on how to configure, compile and run the tests
using `emscripten`:
.. code:: bash
cd rapidyaml
emcmake cmake -S . -B build/emscripten \
-D RYML_DEV=ON \
-D RYML_BUILD_TESTS=ON \
-D RYML_BUILD_BENCHMARKS=OFF \
-D RYML_TEST_SUITE=OFF \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_FLAGS='-s DISABLE_EXCEPTION_CATCHING=0'
cmake --build build/emscripten --target ryml-test-run -j
Python
------

View File

@@ -3055,22 +3055,6 @@ void sample_formatting()
// FTOA_HEXA: AKA %a (hexadecimal formatting of floats)
CHECK("0x1.e8480p+19" == cat_sub(buf, fmt::real(1000000.000000000, 5, FTOA_HEXA))); // AKA %a
CHECK("0x1.2d53ap+20" == cat_sub(buf, fmt::real(1234234.234234234, 5, FTOA_HEXA))); // AKA %a
// Earlier versions of emscripten's sprintf() (from MUSL) do not
// respect some precision values when printing in hexadecimal
// format.
//
// @see https://github.com/biojppm/c4core/pull/52
#if defined(__EMSCRIPTEN__) && __EMSCRIPTEN_major__ < 3
#define _c4emscripten_alt(alt1, alt2) alt2
#else
#define _c4emscripten_alt(alt1, alt2) alt1
#endif
CHECK(_c4emscripten_alt("0x1.2d54p+20", "0x1.2d538p+20")
== cat_sub(buf, fmt::real(1234234.234234234, 4, FTOA_HEXA))); // AKA %a
CHECK("0x1.2d5p+20" == cat_sub(buf, fmt::real(1234234.234234234, 3, FTOA_HEXA))); // AKA %a
CHECK(_c4emscripten_alt("0x1.2dp+20", "0x1.2d8p+20")
== cat_sub(buf, fmt::real(1234234.234234234, 2, FTOA_HEXA))); // AKA %a
#undef _c4emscripten_alt
// --------------------------------------------------------------
// fmt::raw(): dump data in machine format (respecting alignment)

View File

@@ -109,21 +109,23 @@ ryml_add_test_case_group(github_issues)
#-------------------------------------------------------------------------
# test the tools as well
option(RYML_TEST_TOOLS "Enable tests for the tools. Requires file system access." ON)
if(NOT EMSCRIPTEN)
option(RYML_TEST_TOOLS "Enable tests for the tools. Requires file system access." ON)
endif()
if(RYML_TEST_TOOLS)
if(NOT RYML_BUILD_TOOLS)
add_subdirectory(../tools tools)
endif()
add_dependencies(ryml-test-build ryml-parse-emit)
add_dependencies(ryml-test-build ryml-yaml-events)
#
# parse & emit
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/../bm/cases/appveyor.yml)
c4_err("could not find test file")
endif()
ryml_get_target_exe(ryml-parse-emit RYML_TGT_PARSE_EMIT)
add_test(NAME ryml-test-tool-parse_emit COMMAND ${RYML_TGT_PARSE_EMIT} ${CMAKE_CURRENT_LIST_DIR}/../bm/cases/appveyor.yml)
#
# events emitter
function(ryml_create_file name contents fileout)
set(filename ${CMAKE_CURRENT_BINARY_DIR}/${name})