diff options
author | William Langford <wlangfor@gmail.com> | 2018-08-17 22:47:13 -0400 |
---|---|---|
committer | William Langford <wlangfor@gmail.com> | 2018-08-17 23:15:48 -0400 |
commit | 0673dee1b38db5d49ae3f8cda0ba53fa4021c3ba (patch) | |
tree | 4b6f2dedc4115a3dcec65778d5faad42236fa459 /tests | |
parent | 3dc5f4e948b1114c37a9afd3060dacf099892689 (diff) |
Fix destructuring alternationfix-destructuring-alternation
Attempting to use the existing FORK_OPT opcode resulted in difficulty
knowing when to pop an error message off the stack and when not to. This
commit makes DESTRUCTURE_ALT a real opcode that is identical to
FORK_OPT, except for never pushing the error message onto the stack when
continuing from an error backtrack.
Some small changes were necessary to the DUP/POP behavior surrounding
destructuring to accomodate this.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jq.test | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/tests/jq.test b/tests/jq.test index 8771ba65..7e2dd430 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -726,6 +726,107 @@ null [4, 5, null, null, 7, null] [null, null, null, null, null, "foo"] +# Destructuring DUP/POP issues +.[] | . as {a:$a} ?// {a:$a} ?// {a:$a} | $a +[[3],[4],[5],6] +# Runtime error: "jq: Cannot index array with string \"c\"" + +.[] as {a:$a} ?// {a:$a} ?// {a:$a} | $a +[[3],[4],[5],6] +# Runtime error: "jq: Cannot index array with string \"c\"" + +[[3],[4],[5],6][] | . as {a:$a} ?// {a:$a} ?// {a:$a} | $a +null +# Runtime error: "jq: Cannot index array with string \"c\"" + +[[3],[4],[5],6] | .[] as {a:$a} ?// {a:$a} ?// {a:$a} | $a +null +# Runtime error: "jq: Cannot index array with string \"c\"" + +.[] | . as {a:$a} ?// {a:$a} ?// $a | $a +[[3],[4],[5],6] +[3] +[4] +[5] +6 + +.[] as {a:$a} ?// {a:$a} ?// $a | $a +[[3],[4],[5],6] +[3] +[4] +[5] +6 + +[[3],[4],[5],6][] | . as {a:$a} ?// {a:$a} ?// $a | $a +null +[3] +[4] +[5] +6 + +[[3],[4],[5],6] | .[] as {a:$a} ?// {a:$a} ?// $a | $a +null +[3] +[4] +[5] +6 + +.[] | . as {a:$a} ?// $a ?// {a:$a} | $a +[[3],[4],[5],6] +[3] +[4] +[5] +6 + +.[] as {a:$a} ?// $a ?// {a:$a} | $a +[[3],[4],[5],6] +[3] +[4] +[5] +6 + +[[3],[4],[5],6][] | . as {a:$a} ?// $a ?// {a:$a} | $a +null +[3] +[4] +[5] +6 + +[[3],[4],[5],6] | .[] as {a:$a} ?// $a ?// {a:$a} | $a +null +[3] +[4] +[5] +6 + +.[] | . as $a ?// {a:$a} ?// {a:$a} | $a +[[3],[4],[5],6] +[3] +[4] +[5] +6 + +.[] as $a ?// {a:$a} ?// {a:$a} | $a +[[3],[4],[5],6] +[3] +[4] +[5] +6 + +[[3],[4],[5],6][] | . as $a ?// {a:$a} ?// {a:$a} | $a +null +[3] +[4] +[5] +6 + +[[3],[4],[5],6] | .[] as $a ?// {a:$a} ?// {a:$a} | $a +null +[3] +[4] +[5] +6 + . as $dot|any($dot[];not) [1,2,3,4,true,false,1,2,3,4,5] true |