Log step sequence to keep track during tests. OFF BY ONE! OFF BY ONE!

This commit is contained in:
mmcw-dev 2017-12-20 21:59:30 -05:00
parent 11bf8b95f8
commit 19815dbb4d
1 changed files with 6 additions and 4 deletions

View File

@ -59,6 +59,7 @@ sequence.stop = function () {
if (sequence._state.stop) sequence._state.stop() if (sequence._state.stop) sequence._state.stop()
if (sequence._state.input) sequence._state.input() if (sequence._state.input) sequence._state.input()
sequence._state.stop = null sequence._state.stop = null
sequence._state.input = null sequence._state.input = null
} }
@ -73,25 +74,26 @@ sequence.resume = function () {
} }
sequence.step = function () { sequence.step = function () {
log.info('step', `Started step ${sequence._state.count}`)
if (sequence._state.active && !sequence._state.paused) { if (sequence._state.active && !sequence._state.paused) {
if (sequence._state.arr.length > 0) { if (sequence._state.arr.length > 0) {
if (sequence._state.count > sequence._state.arr.length) { if (sequence._state.count > sequence._state.arr.length - 1) {
return sequence.stop() return sequence.stop()
} }
log.info('step') log.info('step', sequence._state.count)
return sequence._state.arr[sequence._state.count](() => { return sequence._state.arr[sequence._state.count](() => {
sequence._state.count++ sequence._state.count++
sequence.step() sequence.step()
}) })
} else if (sequence._loop.arr.length > 0) { } else if (sequence._loop.arr.length > 0) {
if (sequence._state.count > sequence._loop.arr.length) { if (sequence._state.count > sequence._loop.arr.length - 1) {
sequence._state.count = 0 sequence._state.count = 0
sequence._loop.count++ sequence._loop.count++
} }
if (sequence._loop.max > 0 && sequence._loop.count > sequence._loop.max) { if (sequence._loop.max > 0 && sequence._loop.count > sequence._loop.max) {
return sequence.stop() return sequence.stop()
} }
log.info() log.info('step', sequence._state.count)
return sequence._loop.arr[sequence._state.count](() => { return sequence._loop.arr[sequence._state.count](() => {
sequence._state.count++ sequence._state.count++
sequence.step() sequence.step()