Skip to content
Myr

Add a regression test for negative indices and fix a pick/1 test

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

authored by itchyny · committed by Nico Williams · parent f85c9fc · Browse files · 3 files+11 added−10 removed
This commit

State

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

Diff stats

3 files+11 added−10 removed

  • tests:+5 added−5 removed
  • other:+6 added−5 removed

3 files+11 added−10 removed

modified:docs/content/manual/manual.yml+5 added-4 removed
1046 unmodified lines
10471048 - title: "`pick(pathexps)`"1049 body: |10501051 Emit the projection of the input object or array defined by the specified1052 sequence of path expressions, such that if p is any one of these specifications,1053 then `(. | p)` will evaluate to the same value as `(. | pick(pathexps) | p)`.1054 For arrays, negative indices and .[m:n] specifications should not be used.1051 Emit the projection of the input object or array defined by the1052 specified sequence of path expressions, such that if `p` is any1053 one of these specifications, then `(. | p)` will evaluate to the1054 same value as `(. | pick(pathexps) | p)`. For arrays, negative1055 indices and `.[m:n]` specifications should not be used.10561057 examples:1058 - program: 'pick(.a, .b.c, .x)'1059 input: '{"a": 1, "b": {"c": 2, "d": 3}, "e": 4}'
2624 unmodified lines
modified:tests/jq.test+5 added-5 removed
246 unmodified lines
247124822493250251.[-2]251[.[-4,-3,-2,-1,0,1,2,3]]252[1,2,3]2532253[null,1,2,3,1,2,3,null]254255[range(0;10)]256null257[0,1,2,3,4,5,6,7,8,9]
793 unmodified lines
1051[[10,20],30]1052[[10]]10531054# negative indices in path expressions (since last/1 is .[-1])1055pick(last)1056[[10,20],30]1057[null,30]1055try pick(last) catch .1056[1,2]1057"Out of bounds negative array index"10581059#1060# Assignment1061#
965 unmodified lines
modified:jq.1.prebuilt+1 added-1 removed
1048 unmodified lines
1049.1050.IP "" 01051.1052.SS "pick(pathexps)"1053Emit the projection of the input object or array defined by the specified sequence of path expressions, such that if p is any one of these specifications, then \fB(\. | p)\fR will evaluate to the same value as \fB(\. | pick(pathexps) | p)\fR\. For arrays, negative indices and \.[m:n] specifications should not be used\.1053Emit the projection of the input object or array defined by the specified sequence of path expressions, such that if \fBp\fR is any one of these specifications, then \fB(\. | p)\fR will evaluate to the same value as \fB(\. | pick(pathexps) | p)\fR\. For arrays, negative indices and \fB\.[m:n]\fR specifications should not be used\.1054.1055.IP "" 41056.1057.nf
3060 unmodified lines