1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00
Leonid S. Usov cf4b48c7ba Save literal value of the parsed number to preserve it for the output
Extend jv_number to use decNumber for storing number literals. Any math
operations on the numbers will truncate them to double precision.
Comparisons when both numbers are literal numbers will compare them
without truncation.

Delay conversion of numbers to doubles until a math operation is performed,
to preserve precision. A literal jv_number will only need conversion to
double once, and will reuse the resultant double on subsequent
conversions.

Outputting literal jv_numbers preserves the original precision.

Add strong pthread requirement to manage contexts/allocations for
converting numbers between their decNumber, string, and double formats.
2019-10-22 14:11:04 -04:00

44 lines
855 B
Bash
Executable File

#!/bin/sh
# This is meant to be included by each test's shell script driver.
if [ -n "$TRACE_TESTS" ]; then
set -x
fi
set -eu
JQTESTDIR=$(cd "$(dirname "$0")" && pwd)
JQBASEDIR=$JQTESTDIR/..
JQ=$JQBASEDIR/jq
if [ -z "${NO_VALGRIND-}" ] && which valgrind > /dev/null; then
VALGRIND="valgrind --error-exitcode=1 --leak-check=full \
--suppressions=$JQTESTDIR/onig.supp \
--suppressions=$JQTESTDIR/local.supp"
VG_EXIT0=--error-exitcode=0
Q=-q
else
VALGRIND=
VG_EXIT0=
Q=
fi
mods=$JQTESTDIR/modules
clean=true
d=
clean () {
if ! $clean; then
echo "See temp files in $d!"
elif [ -n "$d" ]; then
rm -rf "$d"
fi
}
trap clean EXIT
d=$(mktemp -d -t jqXXXXXX || true)
if [ -z "$d" ]; then
echo "Your OS does not support mktemp(1) -d" 1>&2
exit 1
fi