Skip to content
Myr

Move an example to the manual and regenerate man.test (#2639)

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

authored by itchyny · committed by GitHub · parent 03db550 · Browse files · 3 files+55 added−17 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+55 added−17 removed

  • tests:+47 added−13 removed
  • other:+8 added−4 removed

3 files+55 added−17 removed

modified:docs/content/manual/v1.6/manual.yml+4 added-2 removed
2198 unmodified lines
21992200 The `?` operator, used as `EXP?`, is shorthand for `try EXP`.22012202 examples:2203 - program: '[.[]|(.a)?]'2203 - program: '[.[] | .a?]'2204 input: '[{}, true, {"a":1}]'2205 output: ['[null, 1]']2206 - program: '[.[] | tonumber?]'2207 input: '["1", "invalid", "3", 4]'2208 output: ['[1, 3, 4]']220922072210 - title: Regular expressions2211 body: |22122213 jq uses the Oniguruma regular expression library, as do PHP,
1084 unmodified lines
modified:docs/content/manual/manual.yml+4 added-2 removed
2299 unmodified lines
23002301 The `?` operator, used as `EXP?`, is shorthand for `try EXP`.23022303 examples:2304 - program: '[.[]|(.a)?]'2304 - program: '[.[] | .a?]'2305 input: '[{}, true, {"a":1}]'2306 output: ['[null, 1]']2307 - program: '[.[] | tonumber?]'2308 input: '["1", "invalid", "3", 4]'2309 output: ['[1, 3, 4]']231023082311 - title: Regular expressions2312 body: |23132314 jq uses the
1114 unmodified lines
modified:tests/man.test+47 added-13 removed
1.2"Hello, world!"3"Hello, world!"45. | tojson6123456789098765432123457"12345678909876543212345"89map([., . == 1]) | tojson10[1, 1.000, 1.0, 100e-2]11"[[1,true],[1.000,true],[1.0,true],[1.00,true]]"1213. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000)141000000000000000000000000000000115[true, false]1617.foo18{"foo": 42, "bar": "less interesting data"}194220
153 unmodified lines
1741175-1176177.[] | length166[[1,2], "string", {"a":2}, null]178[[1,2], "string", {"a":2}, null, -5]17921806181118201835184185utf8bytelength186"\u03bc"1872
167 unmodified lines
355flatten356[{"foo": "bar"}, [{"foo": "baz"}]]357[{"foo": "bar"}, {"foo": "baz"}]358346range(2;4)359range(2; 4)360null36123623363351[range(2;4)]364[range(2; 4)]365null366[2,3]367368[range(4)]369null370[0,1,2,3]371359[range(0;10;3)]372[range(0; 10; 3)]373null374[0,3,6,9]375363[range(0;10;-1)]376[range(0; 10; -1)]377null378[]379367[range(0;-5;-1)]380[range(0; -5; -1)]381null382[0,-1,-2,-3,-4]383384floor
178 unmodified lines
563[while(.<100; .*2)]5641565[1,2,4,8,16,32,64]566567[repeat(.*2, error)?]5681569[2]570571[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]572457324574
99 unmodified lines
674true675false676false677661if . == 0 then "zero" elif . == 1 then "one" else "many" end678if . == 0 then "zero" elif . == 1 then "one" else "many" end6792680"many"681682. < 5
39 unmodified lines
722try error("some exception") catch .723true724"some exception"725709[.[]|(.a)?]726[.[] | .a?]727[{}, true, {"a":1}]728[null, 1]729730[.[] | tonumber?]731["1", "invalid", "3", 4]732[1, 3, 4]733734test("foo")735"foo"736true737
123 unmodified lines
861.foo += 1862{"foo": 42}863{"foo": 43}864844.[]|tonumber?845["1", "hello", "3", 4]846184738484865.a = .b866{"a": {"b": 10}, "b": 20}867{"a":20,"b":20}868869.a |= .b870{"a": {"b": 10}, "b": 20}871{"a":10,"b":20}872873(.a, .b) = range(3)874null875{"a":0,"b":0}876{"a":1,"b":1}877{"a":2,"b":2}878879(.a, .b) |= range(3)880null881{"a":0,"b":0}882