Skip to content

Commit

Permalink
test: add test for sequential interrupts
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhayon committed May 27, 2024
1 parent 4ed9a46 commit f98ef5b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/runtime/Runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as $Backdoor from '../effect/Backdoor'
import * as $Exception from '../effect/Exception'
import * as $Interruption from '../effect/Interruption'
import * as $Proxy from '../effect/Proxy'
import * as $Scope from '../effect/Scope'
import { InterruptError } from '../error/InterruptError'
import { MissingLayerError } from '../error/MissingLayerError'
import * as $FiberId from '../fiber/FiberId'
Expand Down Expand Up @@ -352,6 +353,22 @@ describe('Runtime', () => {
// @ts-ignore
expect(`${exit.cause.fiberId}`).toStrictEqual('3')
})

test('interrupting fiber after caught interrupt', async () => {
const exit = await $Runtime.runExit(function* () {
try {
yield* $Scope.scope(function* () {
return yield* $Interruption.interrupt()
})
} catch {
return yield* $Interruption.interrupt()
}
}, $Context.context())

expect(exit).toMatchObject($Exit.failure($Cause.interrupt({} as any)))
// @ts-ignore
expect(`${exit.cause.fiberId}`).toStrictEqual('0')
})
})

describe('runPromise', () => {
Expand Down

0 comments on commit f98ef5b

Please sign in to comment.