mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
fix broken tests in manual.yml
This commit is contained in:
committed by
Nicolas Williams
parent
6083581fea
commit
51a81c96f1
@@ -696,12 +696,12 @@ sections:
|
|||||||
of `has`.
|
of `has`.
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
- program: 'in({"foo": 42})'
|
- program: '.[] | in({"foo": 42})'
|
||||||
input: '"foo", "bar"'
|
input: '["foo", "bar"]'
|
||||||
output: ['true', 'false']
|
output: ['true', 'false']
|
||||||
- program: 'map(in([0,1]))'
|
- program: 'map(in([0,1]))'
|
||||||
input: '[2, 0]'
|
input: '[2, 0]'
|
||||||
output: ['false', 'true']
|
output: ['[false, true]']
|
||||||
|
|
||||||
- title: "`path(path_expression)`"
|
- title: "`path(path_expression)`"
|
||||||
body: |
|
body: |
|
||||||
@@ -1099,7 +1099,7 @@ sections:
|
|||||||
output: ['true', 'false']
|
output: ['true', 'false']
|
||||||
- program: 'infinite, nan | type'
|
- program: 'infinite, nan | type'
|
||||||
input: 'null'
|
input: 'null'
|
||||||
output: ['"number"']
|
output: ['"number"', '"number"']
|
||||||
|
|
||||||
- title: "`sort, sort_by(path_expression)`"
|
- title: "`sort, sort_by(path_expression)`"
|
||||||
body: |
|
body: |
|
||||||
@@ -1281,10 +1281,10 @@ sections:
|
|||||||
input: '["bazzzzz", "bar"]'
|
input: '["bazzzzz", "bar"]'
|
||||||
output: ['false']
|
output: ['false']
|
||||||
- program: 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})'
|
- program: 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})'
|
||||||
input: '{foo: 12, bar: [{barp: 12}]}'
|
input: '{"foo": 12, "bar": [{"barp": 12}]}'
|
||||||
output: ['true']
|
output: ['true']
|
||||||
- program: 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})'
|
- program: 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})'
|
||||||
input: '{foo: 12, bar: [{barp: 15}]}'
|
input: '{"foo": 12, "bar": [{"barp": 15}]}'
|
||||||
output: ['false']
|
output: ['false']
|
||||||
|
|
||||||
- title: "`startswith(str)`"
|
- title: "`startswith(str)`"
|
||||||
@@ -1517,9 +1517,9 @@ sections:
|
|||||||
Rows are padded with nulls so the result is always rectangular.
|
Rows are padded with nulls so the result is always rectangular.
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
- program: 'target'
|
- program: 'transpose'
|
||||||
input: '[[1], [2,3]]'
|
input: '[[1], [2,3]]'
|
||||||
output: ['[1,2],[null,3]']
|
output: ['[[1,2],[null,3]]']
|
||||||
|
|
||||||
- title: "`bsearch(x)`"
|
- title: "`bsearch(x)`"
|
||||||
body: |
|
body: |
|
||||||
@@ -1865,9 +1865,9 @@ sections:
|
|||||||
examples:
|
examples:
|
||||||
- program: 'try .a catch ". is not an object"'
|
- program: 'try .a catch ". is not an object"'
|
||||||
input: 'true'
|
input: 'true'
|
||||||
output: [". is not an object"]
|
output: ['". is not an object"']
|
||||||
- program: '[.[]|try .a]'
|
- program: '[.[]|try .a]'
|
||||||
input: '[{}, true, {"a":1}'
|
input: '[{}, true, {"a":1}]'
|
||||||
output: ['[null, 1]']
|
output: ['[null, 1]']
|
||||||
- program: 'try error("some exception") catch .'
|
- program: 'try error("some exception") catch .'
|
||||||
input: 'true'
|
input: 'true'
|
||||||
@@ -1914,7 +1914,7 @@ sections:
|
|||||||
|
|
||||||
examples:
|
examples:
|
||||||
- program: '[.[]|(.a)?]'
|
- program: '[.[]|(.a)?]'
|
||||||
input: '[{}, true, {"a":1}'
|
input: '[{}, true, {"a":1}]'
|
||||||
output: ['[null, 1]']
|
output: ['[null, 1]']
|
||||||
|
|
||||||
|
|
||||||
@@ -2212,11 +2212,11 @@ sections:
|
|||||||
input: '5'
|
input: '5'
|
||||||
output: ['[10,5]']
|
output: ['[10,5]']
|
||||||
- program: '. as [$a, $b, {c: $c}] | $a + $b + $c'
|
- program: '. as [$a, $b, {c: $c}] | $a + $b + $c'
|
||||||
input: '[2, 3, {c: 4, d: 5}]'
|
input: '[2, 3, {"c": 4, "d": 5}]'
|
||||||
output: ['9']
|
output: ['9']
|
||||||
- program: '.[] as [$a, $b] | {a: $a, b: $b}'
|
- program: '.[] as [$a, $b] | {a: $a, b: $b}'
|
||||||
input: '[[0], [0, 1], [2, 1, 0]]'
|
input: '[[0], [0, 1], [2, 1, 0]]'
|
||||||
output: ['[{"a":0,"b":null},{"a":0,"b":1},{"a":2,"b":1}]']
|
output: ['{"a":0,"b":null}', '{"a":0,"b":1}', '{"a":2,"b":1}']
|
||||||
|
|
||||||
- title: 'Defining Functions'
|
- title: 'Defining Functions'
|
||||||
body: |
|
body: |
|
||||||
@@ -2319,7 +2319,7 @@ sections:
|
|||||||
examples:
|
examples:
|
||||||
- program: '[first(range(.)), last(range(.)), nth(./2; range(.))]'
|
- program: '[first(range(.)), last(range(.)), nth(./2; range(.))]'
|
||||||
input: '10'
|
input: '10'
|
||||||
output: ['[0,9,4]']
|
output: ['[0,9,5]']
|
||||||
|
|
||||||
- title: "`first`, `last`, `nth(n)`"
|
- title: "`first`, `last`, `nth(n)`"
|
||||||
body: |
|
body: |
|
||||||
@@ -2426,7 +2426,7 @@ sections:
|
|||||||
select((by > 0 and . < upto) or (by < 0 and . > upto));
|
select((by > 0 and . < upto) or (by < 0 and . > upto));
|
||||||
range(0; 10; 3)'
|
range(0; 10; 3)'
|
||||||
input: 'null'
|
input: 'null'
|
||||||
output: ['0,3,6,9']
|
output: ['0', '3', '6', '9']
|
||||||
- program: 'def while(cond; update):
|
- program: 'def while(cond; update):
|
||||||
def _while:
|
def _while:
|
||||||
if cond then ., (update | _while) else empty end;
|
if cond then ., (update | _while) else empty end;
|
||||||
|
12
jq_test.c
12
jq_test.c
@@ -122,14 +122,22 @@ static void run_jq_tests(jv lib_dirs, FILE *testdata) {
|
|||||||
if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; }
|
if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; }
|
||||||
lineno++;
|
lineno++;
|
||||||
jv input = jv_parse(buf);
|
jv input = jv_parse(buf);
|
||||||
if (!jv_is_valid(input)){ invalid++; continue; }
|
if (!jv_is_valid(input)) {
|
||||||
|
printf("*** Input is invalid on line %u: %s\n", lineno, buf);
|
||||||
|
invalid++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
jq_start(jq, input, JQ_DEBUG_TRACE);
|
jq_start(jq, input, JQ_DEBUG_TRACE);
|
||||||
|
|
||||||
while (fgets(buf, sizeof(buf), testdata)) {
|
while (fgets(buf, sizeof(buf), testdata)) {
|
||||||
lineno++;
|
lineno++;
|
||||||
if (skipline(buf)) break;
|
if (skipline(buf)) break;
|
||||||
jv expected = jv_parse(buf);
|
jv expected = jv_parse(buf);
|
||||||
if (!jv_is_valid(expected)){ invalid++; continue; }
|
if (!jv_is_valid(expected)) {
|
||||||
|
printf("*** Expected result is invalid on line %u: %s\n", lineno, buf);
|
||||||
|
invalid++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
jv actual = jq_next(jq);
|
jv actual = jq_next(jq);
|
||||||
if (!jv_is_valid(actual)) {
|
if (!jv_is_valid(actual)) {
|
||||||
jv_free(actual);
|
jv_free(actual);
|
||||||
|
Reference in New Issue
Block a user