Skip to content
Myr

Remove scalars_or_empty

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Muh Muhten · committed by Nico Williams · parent 36c250a · Browse files · 2 files+1 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+1 added−2 removed

  • tests:+1 added−1 removed
  • other:+0 added−1 removed

2 files+1 added−2 removed

modified:src/builtin.jq-1 removed
56 unmodified lines
57def strings: select(type == "string");58def nulls: select(type == "null");59def values: select(. != null);60def scalars: select(. == null or . == true or . == false or type == "number" or type == "string");61def scalars_or_empty: select(. == null or . == true or . == false or type == "number" or type == "string" or ((type=="array" or type=="object") and length==0));61def leaf_paths: paths(scalars);62def join($x): reduce .[] as $i (null;63 (if .==null then "" else .+$x end) +64 ($i | if type=="boolean" or type=="number" then tostring else .//"" end)
248 unmodified lines
modified:tests/shtest+1 added-1 removed
153 unmodified lines
154## Test streaming parser155156## If we add an option to stream to the `import ... as $symbol;` directive157## then we can move these tests into tests/all.test.158$VALGRIND $Q $JQ -c '. as $d|path(..) as $p|$d|getpath($p)|scalars_or_empty|[$p,.]' < "$JQTESTDIR/torture/input0.json" > $d/out0158$VALGRIND $Q $JQ -c '. as $d|path(..) as $p|$d|getpath($p)|select((type|. != "array" and . != "object") or length==0)|[$p,.]' < "$JQTESTDIR/torture/input0.json" > $d/out0159$VALGRIND $Q $JQ --stream -c '.|select(length==2)' < "$JQTESTDIR/torture/input0.json" > $d/out1160diff $d/out0 $d/out1161162## XXX This test can be moved to tests/all.test _now_
168 unmodified lines