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
Provenance
- Commit
f88c4e5- Tree
f3053a3- Author
itchyny <itchyny@cybozu.co.jp>- Committer
GitHub <noreply@github.com>- Parent
03db550
3 files changed+55 added−17 removed
modified:docs/content/manual/v1.6/manual.yml+4 added-2 removed
2198 unmodified lines2199 2200 The `?` operator, used as `EXP?`, is shorthand for `try EXP`.2201 2202 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]']2209 2207-2210 - title: Regular expressions2211 body: |2212 2213 jq uses the Oniguruma regular expression library, as do PHP,1084 unmodified linesmodified:docs/content/manual/manual.yml+4 added-2 removed
2299 unmodified lines2300 2301 The `?` operator, used as `EXP?`, is shorthand for `try EXP`.2302 2303 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]']2310 2308-2311 - title: Regular expressions2312 body: |2313 2314 jq uses the1114 unmodified linesmodified:tests/man.test+47 added-13 removed
1 .2 "Hello, world!"3 "Hello, world!"4 5+. | tojson6+123456789098765432123457+"12345678909876543212345"8+9+map([., . == 1]) | tojson10+[1, 1.000, 1.0, 100e-2]11+"[[1,true],[1.000,true],[1.0,true],[1.00,true]]"12+13+. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000)14+1000000000000000000000000000000115+[true, false]16+17 .foo18 {"foo": 42, "bar": "less interesting data"}19 4220 153 unmodified lines174 1175 -1176 177 .[] | length166-[[1,2], "string", {"a":2}, null]178+[[1,2], "string", {"a":2}, null, -5]179 2180 6181 1182 0183+5184 185 utf8bytelength186 "\u03bc"187 2167 unmodified lines355 flatten356 [{"foo": "bar"}, [{"foo": "baz"}]]357 [{"foo": "bar"}, {"foo": "baz"}]358 346-range(2;4)359+range(2; 4)360 null361 2362 3363 351-[range(2;4)]364+[range(2; 4)]365 null366 [2,3]367 368 [range(4)]369 null370 [0,1,2,3]371 359-[range(0;10;3)]372+[range(0; 10; 3)]373 null374 [0,3,6,9]375 363-[range(0;10;-1)]376+[range(0; 10; -1)]377 null378 []379 367-[range(0;-5;-1)]380+[range(0; -5; -1)]381 null382 [0,-1,-2,-3,-4]383 384 floor178 unmodified lines563 [while(.<100; .*2)]564 1565 [1,2,4,8,16,32,64]566 567+[repeat(.*2, error)?]568+1569+[2]570+571 [.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]572 4573 24574 99 unmodified lines674 true675 false676 false677 661-if . == 0 then "zero" elif . == 1 then "one" else "many" end678+if . == 0 then "zero" elif . == 1 then "one" else "many" end679 2680 "many"681 682 . < 539 unmodified lines722 try error("some exception") catch .723 true724 "some exception"725 709-[.[]|(.a)?]726+[.[] | .a?]727 [{}, true, {"a":1}]728 [null, 1]729 730+[.[] | tonumber?]731+["1", "invalid", "3", 4]732+[1, 3, 4]733+734 test("foo")735 "foo"736 true737 123 unmodified lines861 .foo += 1862 {"foo": 42}863 {"foo": 43}864 844-.[]|tonumber?845-["1", "hello", "3", 4]846-1847-3848-4865+.a = .b866+{"a": {"b": 10}, "b": 20}867+{"a":20,"b":20}868+869+.a |= .b870+{"a": {"b": 10}, "b": 20}871+{"a":10,"b":20}872+873+(.a, .b) = range(3)874+null875+{"a":0,"b":0}876+{"a":1,"b":1}877+{"a":2,"b":2}878+879+(.a, .b) |= range(3)880+null881+{"a":0,"b":0}882+