/**
 * B20 regression: WorkerProcess exit code 4 semantic mismatch
 * Bug: exit code 4 mapped to 'blocked' but spec says 'parent_cancelled'.
 */

import { describe, it, expect } from 'bun:test'
import { WorkerProcess } from '../../src/workers/WorkerProcess.js'

describe('B20: WorkerProcess exit code 4', () => {
  const wp = new WorkerProcess()

  it('exit code 4 semantic is parent_cancelled not blocked', () => {
    const info = wp.get_exit_code_info(4)
    expect(info).toBeDefined()
    expect(info!.semantic).toBe('parent_cancelled')
    expect(info!.semantic).not.toBe('blocked')
  })

  it('exit code 4 description mentions cancelled', () => {
    const info = wp.get_exit_code_info(4)
    expect(info!.description.toLowerCase()).toContain('cancel')
  })

  it('all 6 exit codes (0-5) have entries', () => {
    for (let code = 0; code <= 5; code++) {
      expect(wp.get_exit_code_info(code)).toBeDefined()
    }
  })

  it('exit code 0 is normal', () => {
    expect(wp.get_exit_code_info(0)!.semantic).toBe('normal')
  })
})
