mirror of
https://github.com/wader/fq.git
synced 2024-11-30 09:58:13 +03:00
46 lines
1.1 KiB
Plaintext
46 lines
1.1 KiB
Plaintext
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
|
|
)
|
|
)
|
|
,
|
|
([
|
|
["", "[.[] | .] | ."],
|
|
[".", "[.[] | .] | ."],
|
|
["a", "[.[] | .] | a"],
|
|
["1, 2", "[.[] | .] | 1, 2"],
|
|
["1 | 2", "[.[] | 1 | .] | 2"],
|
|
["1 | 2 | 3", "[.[] | 1 | 2 | .] | 3"],
|
|
["(1 | 2) | 3", "[.[] | (1 | 2) | .] | 3"],
|
|
["1 | (2 | 3)", "[.[] | 1 | .] | (2 | 3)"],
|
|
["1 as $_ | 2", "[.[] | 1 as $_ | .] | 2"],
|
|
["def f: 1; 1", "[.[] | .] | def f: 1; 1"],
|
|
["def f: 1; 1 | 2", "[.[] | def f: 1; 1 | .] | 2"],
|
|
["module {};\ninclude \"a\";\n1", "module {};\ninclude \"a\";\n[.[] | .] | 1"],
|
|
empty
|
|
][] | assert(
|
|
"\(.) | _query_slurp_wrap";
|
|
.[1];
|
|
.[0] | _query_fromstring | _query_slurp_wrap(.) | _query_tostring
|
|
)
|
|
)
|
|
)
|