Every *.test file here is a list of cases that each implementation of jqlite (the reference
in C# and every port) must pass. The format is the one of jq's own tests/jq.test.
The file is UTF-8, read line by line. A line ends at LF (U+000A); a CR just before the LF is part of
the line ending, and a lone CR is part of the line (syntax.test has a program with one). Blank
lines and lines starting with # separate cases.
A normal case is a group of consecutive lines:
[try (1, error("x"), 3) catch .]
null
[1,"x"]
A case that starts with a %%FAIL line is a program that must fail to parse or to bind (spec §10.2):
%%FAIL
. as $foo | break $foo
$*label-foo is not defined
The lines after the program are the error message. A line that is one of the fixed texts of spec
§10.2 (f/1 is not defined, $*label-foo is not defined, Cannot use number (0) as object key,
…) must be contained in the implementation's message; other lines are jq's own wording and are not
compared. With %%FAIL IGNORE MSG no line is compared.
$ENV and the default depth limit, and collect every output.halt. An uncaught error or halt_error fails the case;
cases that test an error catch it in the program (try ... catch .), so the message is an
ordinary output.Each output is written as canonical text (spec §5.1) and read back, so NaN compares as null and
±Infinity as ±1.7976931348623157e+308, the way jq prints them. Each expected line is parsed as JSON
and compared structurally with it:
1, 1.0 and 1e0 are equal, and so are -0 and 0);Number formatting and string escaping are therefore not compared on outputs: cases that test the
text of a value produce it as a string inside the program (tojson, tostring, @json, @text).
modules.test runs with the module files of modules/ (spec §9.11, §14.2): a path p in an
import or include names the file p.jq (code) or p.json (data) in the directory of the file
that holds the directive, the main program's directory being modules/. The identity of a module
is that file. A path that names no file is a missing module. A port without the modules group
skips this file.
Expected outputs do not depend on the machine (environment variables, current time, culture), except:
localtime.test runs with the host time zone fixed at UTC+02:00, with no daylight saving time.