Skip to content
Myr

Fix range(value;stream) (fix #886)

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

authored by David Tolnay · committed by David Tolnay · parent d66fbd2 · Browse files · 2 files+16 added−2 removed
This commit

State

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

Diff stats

2 files+16 added−2 removed

  • tests:+8 added−0 removed
  • other:+8 added−2 removed

2 files+16 added−2 removed

modified:tests/jq.test+8 added
229 unmodified lines
230[range(0;10)]231null232[0,1,2,3,4,5,6,7,8,9]233234[range(0,1;3,4)]235null236[0,1,2, 0,1,2,3, 1,2, 1,2,3]237238[range(0;10;3)]239null240[0,3,6,9]241
4 unmodified lines
246[range(0;-5;-1)]247null248[0,-1,-2,-3,-4]249250[range(0,1;4,5;1,2)]251null252[0,1,2,3,0,2, 0,1,2,3,4,0,2,4, 1,2,3,1,3, 1,2,3,4,1,3]253254[while(.<100; .*2)]2551256[1,2,4,8,16,32,64]257
982 unmodified lines
modified:builtin.c+8 added-2 removed
1337 unmodified lines
1338 }1339 {1340 // Note that we can now define `range` as a jq-coded function1341 block rangevar = gen_op_var_fresh(STOREV, "rangevar");1342 block init = BLOCK(gen_op_simple(DUP), gen_call("start", gen_noop()), rangevar);1343 block range = BLOCK(init,1342 block rangestart = gen_op_var_fresh(STOREV, "rangestart");1343 block range = BLOCK(gen_op_simple(DUP),1344 gen_call("start", gen_noop()),1345 rangestart,1346 gen_call("end", gen_noop()),1347 gen_op_simple(DUP),1348 gen_op_bound(LOADV, rangestart),1349 // Reset rangevar for every value generated by "end"1350 rangevar,1351 gen_op_bound(RANGE, rangevar));1352 builtins = BLOCK(builtins, gen_function("range",1353 BLOCK(gen_param("start"), gen_param("end")),1354 range));
336 unmodified lines