Make tests pass when --disable-decnum

This commit is contained in:
Nicolas Williams authored and Nico Williams committed 2024-05-15 12:48:00 -05:00
1 parent c1276169d6
commit 6d02d53f51
8 files changed
+88 -37

No files matched your search

+11
View File
@@ -1741,6 +1741,15 @@ static jv f_current_line(jq_state *jq, jv a) {
return jq_util_input_get_current_line(jq);
}
static jv f_have_decnum(jq_state *jq, jv a) {
jv_free(a);
#ifdef USE_DECNUM
return jv_true();
#else
return jv_false();
#endif
}
#define LIBM_DD(name) \
{f_ ## name, #name, 1},
#define LIBM_DD_NO(name) LIBM_DD(name)
@@ -1818,6 +1827,8 @@ BINOPS
{f_now, "now", 1},
{f_current_filename, "input_filename", 1},
{f_current_line, "input_line_number", 1},
{f_have_decnum, "have_decnum", 1},
{f_have_decnum, "have_literal_numbers", 1},
};
#undef LIBM_DDDD_NO
#undef LIBM_DDD_NO
+2
View File
@@ -208,11 +208,13 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int
printf(" for test at line number %u: %s\n", lineno, prog);
pass = 0;
}
#ifdef USE_DECNUM
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT));
jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string)));
assert(jv_equal(jv_copy(expected), jv_copy(reparsed)));
jv_free(as_string);
jv_free(reparsed);
#endif
jv_free(expected);
jv_free(actual);
}