# Tests are groups of three lines: program, input, expected output # Blank lines and lines starting with # are ignored # The input line starts with a 0xFEFF (byte order mark) codepoint # We test escapes by matching them against Unicode codepoints # Field access, piping # module system # Multiple outputs, iteration # Check that various builtins evaluate all arguments where appropriate, # doing cartesian products where appropriate. # Try/catch and general `?` operator # And some in/equality tests # Basic numbers tests: integers, powers of two # Negative array indices # Slices # abs, fabs, length # Builtin functions # containment operator # Conditionals [label $out | foreach .[] as $item ([3, null]; if .[0] < 1 then break $out else [.[0] -1, $item] end; .[1])] [foreach .[] as $x (0; . + $x) as $x | $x] # test recursion # Variables def f(a;b;c;d;e;f): [a+1,b,c,d,e,f]; f(.[0];.[1];.[0];.[0];.[0];.[0]) # test multiple function arities and redefinition # Destructuring with alternation # Paths ["foo",1] as $p | getpath($p), setpath($p; 20), delpaths([$p]) # # Assignment # .message = "goodbye" # #1358, getpath/1 should work in path expressions # Collection transformations sort [42,[2,5,3,11],10,{"a":42,"b":2},{"a":42},true,2,[2,6],"hello",null,[2,5,6],{"a":[],"b":1},"abc","ab",[3,10],{},false,"abcd",null] to_entries {"a": 1, "b": 2} [{"key":"a", "value":1}, {"key":"b", "value":2}] # check that dead code removal occurs after builtin it generation # string operations [.[]|tojson|fromjson] ["foo", 1, ["a", 1, "b", 2, {"foo":"bar"}]] ["foo",1,["a",1,"b",2,{"foo":"bar"}]] # string operations # module system # calling input/0, or debug/0 in a test doesn't crash jq debug 1 1 # Multiple outputs, iteration # Tests are groups of three lines: program, input, expected output