]> granicus.if.org Git - jq/commitdiff
Remove scalars_or_empty
authorMuh Muhten <muh.muhten@gmail.com>
Tue, 26 Feb 2019 04:53:21 +0000 (23:53 -0500)
committerNico Williams <nico@cryptonector.com>
Tue, 26 Feb 2019 17:05:25 +0000 (11:05 -0600)
src/builtin.jq
tests/shtest

index d3a4bb16d19324a7a53740007568ce1def1bc644..23c5a5647c0f37cee1540843c21344f620f7e2e7 100644 (file)
@@ -58,7 +58,6 @@ def strings: select(type == "string");
 def nulls: select(type == "null");
 def values: select(. != null);
 def scalars: select(. == null or . == true or . == false or type == "number" or type == "string");
-def scalars_or_empty: select(. == null or . == true or . == false or type == "number" or type == "string" or ((type=="array" or type=="object") and length==0));
 def leaf_paths: paths(scalars);
 def join($x): reduce .[] as $i (null;
             (if .==null then "" else .+$x end) +
index fc2ef1523089ca49c704a58b85d6dda699d4df0c..a4fec6d6aff1526a6ec76bc618fb9c89fe34e4f8 100755 (executable)
@@ -155,7 +155,7 @@ cmp $d/out $d/expected
 
 ## If we add an option to stream to the `import ... as $symbol;` directive
 ## then we can move these tests into tests/all.test.
-$VALGRIND $Q $JQ -c '. as $d|path(..) as $p|$d|getpath($p)|scalars_or_empty|[$p,.]' < "$JQTESTDIR/torture/input0.json" > $d/out0
+$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/out0
 $VALGRIND $Q $JQ --stream -c '.|select(length==2)' < "$JQTESTDIR/torture/input0.json" > $d/out1
 diff $d/out0 $d/out1