Skip to content

Commit

Permalink
Variable arguments last to counted or each loops.
Browse files Browse the repository at this point in the history
Always put the variables arguments last when the loop is a counted loop
or an each loop.

Closes #193.
  • Loading branch information
flatheadmill committed Feb 23, 2014
1 parent eea8823 commit efb9ea3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ function cadence () {
callback.steps.unshift(function () {
var vargs = __slice.call(arguments)
if (whilst()) {
step().apply(this, [null].concat(each ? [counter[count]] : vargs).concat([count]))
if (counter) {
step().apply(this, [].concat.apply([null], [ each ? counter[count] : [], count, vargs ]))
} else {
step().apply(this, [null].concat(vargs).concat([ count ]))
}
} else if (gather) {
var release = createHandler(frame, false, [0])
step.apply(this, [null].concat(vargs))
Expand Down
3 changes: 3 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Issue by Issue

* Variable arguments last to counted or each loops. #193.
2 changes: 1 addition & 1 deletion t/cadence/loop.t.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ require('proof')(19, function (step, equal, deepEqual) {

cadence(function (step) {
var outer = { count: 0, flag: true }
step(function (flag, count) {
step(function (count, flag) {
equal(flag, outer.flag, 'got flag in counted loop ' + (count + 1))
equal(count, outer.count++, 'got count in counted loop' + (count + 1))
outer.flag = false
Expand Down

0 comments on commit efb9ea3

Please sign in to comment.