1
1
mirror of https://github.com/wader/fq.git synced 2024-12-26 15:02:28 +03:00
fq/pkg/interp/query_test.jq

46 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-09-04 01:54:51 +03:00
include "assert";
include "query";
(
([
["", "."],
[".", "."],
["a", "a"],
["1, 2", "1, 2"],
["1 | 2", "2"],
["1 | 2 | 3", "3"],
["(1 | 2) | 3", "3"],
["1 | (2 | 3)", "(2 | 3)"],
["1 as $_ | 2", "2"],
["def f: 1; 1", "def f: 1; 1"],
["def f: 1; 1 | 2", "2"],
empty
][] | assert(
"\(.) | _query_pipe_last";
.[1];
.[0] | _query_fromstring | _query_pipe_last | _query_tostring
)
)
,
([
2021-09-05 14:04:58 +03:00
["", "map(.) | ."],
[".", "map(.) | ."],
["a", "map(.) | a"],
["1, 2", "map(.) | 1, 2"],
["1 | 2", "map(1 | .) | 2"],
["1 | 2 | 3", "map(1 | 2 | .) | 3"],
["(1 | 2) | 3", "map((1 | 2) | .) | 3"],
["1 | (2 | 3)", "map(1 | .) | (2 | 3)"],
["1 as $_ | 2", "map(1 as $_ | .) | 2"],
["def f: 1; 1", "map(.) | def f: 1; 1"],
["def f: 1; 1 | 2", "map(def f: 1; 1 | .) | 2"],
["module {a:1};\ninclude \"a\";\n1", "module { a: 1 };\ninclude \"a\";\nmap(.) | 1"],
2021-09-04 01:54:51 +03:00
empty
][] | assert(
"\(.) | _query_slurp_wrap";
.[1];
.[0] | _query_fromstring | _query_slurp_wrap(.) | _query_tostring
)
)
)