Created
March 31, 2020 18:14
-
-
Save diafour/3b3d8f123b642ff095c41c16d6f32d0e to your computer and use it in GitHub Desktop.
jq fromjson or tostring problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try (tonumber) catch ("Should catch error") | |
"a20" | |
"Should catch error" | |
# Tests are groups of three lines: program, input, expected output | |
# Blank lines and lines starting with # are ignored | |
# | |
# Simple value tests to check parser. Input is irrelevant | |
# | |
true | |
null | |
true | |
false | |
null | |
false | |
# truncated ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
================================================ | |
jq 1.6-99-gcf4b48c-dirty: ./test-suite.log | |
================================================ | |
# TOTAL: 6 | |
# PASS: 5 | |
# SKIP: 0 | |
# XFAIL: 0 | |
# FAIL: 1 | |
# XPASS: 0 | |
# ERROR: 0 | |
.. contents:: :depth: 2 | |
FAIL: tests/jqtest | |
================== | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '5') at <builtin>, line 1: | |
def halt_error: halt_error(5); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 7: | |
def unique: group_by(.) | map(.[0]); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 8: | |
def unique_by(f): group_by(f) | map(.[0]); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 26: | |
def reverse: [.[length - 1 - range(0;length)]]; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 26: | |
def reverse: [.[length - 1 - range(0;length)]]; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 31: | |
def index($i): indices($i) | .[0]; # TODO: optimize | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 32: | |
def rindex($i): indices($i) | .[-1:][0]; # TODO: optimize | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 32: | |
def rindex($i): indices($i) | .[-1:][0]; # TODO: optimize | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 33: | |
def paths: path(recurse(if (type|. == "array" or . == "object") then .[] else empty end))|select(length > 0); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 52: | |
def _flatten($x): reduce .[] as $i ([]; if $i | type == "array" and $x != 0 then . + ($i | _flatten($x-1)) else . + [$i] end); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 52: | |
def _flatten($x): reduce .[] as $i ([]; if $i | type == "array" and $x != 0 then . + ($i | _flatten($x-1)) else . + [$i] end); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 53: | |
def flatten($x): if $x < 0 then error("flatten depth must not be negative") else _flatten($x) end; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 54: | |
def flatten: _flatten(-1); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 55: | |
def range($x): range(0;$x); | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 62: | |
elif $vt == "array" and ($val | length) > 1 then match($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 62: | |
elif $vt == "array" and ($val | length) > 1 then match($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 62: | |
elif $vt == "array" and ($val | length) > 1 then match($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 63: | |
elif $vt == "array" and ($val | length) > 0 then match($val[0]; null) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 63: | |
elif $vt == "array" and ($val | length) > 0 then match($val[0]; null) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 67: | |
elif $vt == "array" and ($val | length) > 1 then test($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 67: | |
elif $vt == "array" and ($val | length) > 1 then test($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 67: | |
elif $vt == "array" and ($val | length) > 1 then test($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 68: | |
elif $vt == "array" and ($val | length) > 0 then test($val[0]; null) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 68: | |
elif $vt == "array" and ($val | length) > 0 then test($val[0]; null) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 72: | |
elif $vt == "array" and ($val | length) > 1 then capture($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 72: | |
elif $vt == "array" and ($val | length) > 1 then capture($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 72: | |
elif $vt == "array" and ($val | length) > 1 then capture($val[0]; $val[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 73: | |
elif $vt == "array" and ($val | length) > 0 then capture($val[0]; null) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 73: | |
elif $vt == "array" and ($val | length) > 0 then capture($val[0]; null) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 77: | |
| if (.captures|length > 0) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 84: | |
def _nwise(a; $n): if a|length <= $n then a else a[0:$n] , _nwise(a[$n:]; $n) end; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 91: | |
| [0] + . +[$s|length] | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 92: | |
| _nwise(2) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 93: | |
| $s[.[0]:.[1] ] ; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 93: | |
| $s[.[0]:.[1] ] ; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 103: | |
| if length == 0 then $in | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 104: | |
else .[0] | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 109: | |
| $in[0:$r.offset] + s + $in[$r.offset+$r.length:] | |
jq: error: Invalid numeric literal at EOF at line 1, column 3 (while parsing '103') at <builtin>, line 114: | |
def subg: [explode[] | select(. != 103)] | implode; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 120: | |
| if length == 0 then $in | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 121: | |
else .[0] as $edit | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 126: | |
| $in[0:$edit.offset] | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 128: | |
+ ($in[$len:] | if length > 0 and gs then mysub else . end) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 151: | |
if $n > 0 then label $out | foreach exp as $item ($n; .-1; $item, if . <= 0 then break $out else empty end) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 151: | |
if $n > 0 then label $out | foreach exp as $item ($n; .-1; $item, if . <= 0 then break $out else empty end) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 151: | |
if $n > 0 then label $out | foreach exp as $item ($n; .-1; $item, if . <= 0 then break $out else empty end) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 152: | |
elif $n == 0 then empty | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 156: | |
if $by > 0 then $init|while(. < $upto; . + $by) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 157: | |
elif $by < 0 then $init|while(. > $upto; . + $by) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 168: | |
def nth($n; g): if $n < 0 then error("nth doesn't support negative indices") else last(limit($n + 1; g)) end; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 168: | |
def nth($n; g): if $n < 0 then error("nth doesn't support negative indices") else last(limit($n + 1; g)) end; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 169: | |
def first: .[0]; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 170: | |
def last: .[-1]; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 173: | |
if length == 0 then [] else | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 174: | |
.[0][] as $x | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 175: | |
| (.[1:] | combinations) as $y | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 189: | |
| reduce range(0; $max) as $j | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 190: | |
([]; . + [reduce range(0;$length) as $i ([]; . + [ $in[$i][$j] ] )] ) | |
jq: error: Invalid numeric literal at EOF at line 1, column 2 (while parsing '65') at <builtin>, line 201: | |
explode | map( if 65 <= . and . <= 90 then . + 32 else . end) | implode; | |
jq: error: Invalid numeric literal at EOF at line 1, column 2 (while parsing '90') at <builtin>, line 201: | |
explode | map( if 65 <= . and . <= 90 then . + 32 else . end) | implode; | |
jq: error: Invalid numeric literal at EOF at line 1, column 2 (while parsing '32') at <builtin>, line 201: | |
explode | map( if 65 <= . and . <= 90 then . + 32 else . end) | implode; | |
jq: error: Invalid numeric literal at EOF at line 1, column 2 (while parsing '97') at <builtin>, line 204: | |
explode | map( if 97 <= . and . <= 122 then . - 32 else . end) | implode; | |
jq: error: Invalid numeric literal at EOF at line 1, column 3 (while parsing '122') at <builtin>, line 204: | |
explode | map( if 97 <= . and . <= 122 then . - 32 else . end) | implode; | |
jq: error: Invalid numeric literal at EOF at line 1, column 2 (while parsing '32') at <builtin>, line 204: | |
explode | map( if 97 <= . and . <= 122 then . - 32 else . end) | implode; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 208: | |
. as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][$n:]) else empty end; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 208: | |
. as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][$n:]) else empty end; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 208: | |
. as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][$n:]) else empty end; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 213: | |
| if $i|length == 2 | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 214: | |
then setpath(["e"]; $i[0]|length==0) | setpath(["x"]+$i[0]; $i[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 214: | |
then setpath(["e"]; $i[0]|length==0) | setpath(["x"]+$i[0]; $i[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 214: | |
then setpath(["e"]; $i[0]|length==0) | setpath(["x"]+$i[0]; $i[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 214: | |
then setpath(["e"]; $i[0]|length==0) | setpath(["x"]+$i[0]; $i[1]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 215: | |
else setpath(["e"]; $i[0]|length==1) end | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 215: | |
else setpath(["e"]; $i[0]|length==1) end | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 228: | |
if length == 0 then -1 | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 228: | |
if length == 0 then -1 | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 229: | |
elif length == 1 then | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 230: | |
if $target == .[0] then 0 elif $target < .[0] then -1 else -2 end | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 230: | |
if $target == .[0] then 0 elif $target < .[0] then -1 else -2 end | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 230: | |
if $target == .[0] then 0 elif $target < .[0] then -1 else -2 end | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 230: | |
if $target == .[0] then 0 elif $target < .[0] then -1 else -2 end | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 230: | |
if $target == .[0] then 0 elif $target < .[0] then -1 else -2 end | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 234: | |
| [0, length-1, null] | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 234: | |
| [0, length-1, null] | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 235: | |
| until( .[0] > .[1] ; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 235: | |
| until( .[0] > .[1] ; | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 236: | |
if .[2] != null then (.[1] = -1) # i.e. break | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 236: | |
if .[2] != null then (.[1] = -1) # i.e. break | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 236: | |
if .[2] != null then (.[1] = -1) # i.e. break | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 238: | |
( ( (.[1] + .[0]) / 2 ) | floor ) as $mid | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 238: | |
( ( (.[1] + .[0]) / 2 ) | floor ) as $mid | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 238: | |
( ( (.[1] + .[0]) / 2 ) | floor ) as $mid | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 240: | |
| if $monkey == $target then (.[2] = $mid) # success | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 241: | |
elif .[0] == .[1] then (.[1] = -1) # failure | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 241: | |
elif .[0] == .[1] then (.[1] = -1) # failure | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 241: | |
elif .[0] == .[1] then (.[1] = -1) # failure | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 241: | |
elif .[0] == .[1] then (.[1] = -1) # failure | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 242: | |
elif $monkey < $target then (.[0] = ($mid + 1)) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 242: | |
elif $monkey < $target then (.[0] = ($mid + 1)) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 243: | |
else (.[1] = ($mid - 1)) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 243: | |
else (.[1] = ($mid - 1)) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 246: | |
| if .[2] == null then # compute the insertion point | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 247: | |
if $in[ .[0] ] < $target then (-2 -.[0]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 247: | |
if $in[ .[0] ] < $target then (-2 -.[0]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 247: | |
if $in[ .[0] ] < $target then (-2 -.[0]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '1') at <builtin>, line 248: | |
else (-1 -.[0]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '0') at <builtin>, line 248: | |
else (-1 -.[0]) | |
jq: error: Invalid numeric literal at EOF at line 1, column 1 (while parsing '2') at <builtin>, line 250: | |
else .[2] | |
jq: src/builtin.c:1806: builtins_bind: Assertion `!nerrors' failed. | |
Testing 'try (tonumber) catch ("Should catch error")' at line number 1 | |
Testing 'true' at line number 12 | |
Aborted | |
FAIL tests/jqtest (exit status: 134) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment