Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit c514525

Browse files
authored
Add missing exit state to composer.try FSM (#44)
Fixes #43
1 parent 51136d3 commit c514525

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

composer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ function init(__eval__, composition) {
342342
case 'try':
343343
var body = compile(json.body, path + '.body')
344344
const handler = chain(compile(json.handler, path + '.handler'), [{ type: 'pass', path }])
345-
var fsm = [[{ type: 'try', path }], body].reduce(chain)
345+
var fsm = [[{ type: 'try', path }], body, [{ type: 'exit', path }]].reduce(chain)
346346
fsm[0].catch = fsm.length
347347
fsm.slice(-1)[0].next = handler.length
348348
fsm.push(...handler)

test/test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ describe('composer', function () {
427427
.then(activation => assert.deepEqual(activation.response.result, { message: 'foo' }))
428428
})
429429

430+
it('retain', function () {
431+
return invoke(composer.retain(composer.try(() => ({ p: 4 }))), { n: 3 })
432+
.then(activation => assert.deepEqual(activation.response.result, { params: { n: 3 }, result: { p: 4 } }))
433+
})
434+
430435
it('invalid options', function () {
431436
try {
432437
invoke(composer.try('isNotOne', 'isNotOne', 'isNotOne'))

0 commit comments

Comments
 (0)